Obviously it would be more elegant to have a dedicated method to do this in RS, but maybe this would help you for now - see attached (True or False in the main Sub call will sort ascending or descending).
Initially, the request was to mimic the sort action created by pressing the layer list header.
Having used the workaround script provided by @Jarek , which sorts the parent layers and single layers (no children), I can see a use for this method, which keeps the children layers unsorted, as well as a method to sort the complete list.
A third method to sort the children layers of a (current?) parent layer would be handy too.
I reworked the script to act on current layer only (and its all children or immediate children - use the proper argument).
Seems to be working fine except on files with tons of layers may take a couple seconds to refresh the panel…
It could probably be made faster by creating 2 temporary parent folders and juggling between them to sort, but ran out of time for now to implement this way. Hope this one helps for now.
This script works well Jarek, the refresh time isn’t a problem. Thank you for the effort you’ve put into this, you have provided a variety of ways to keep the layer list tidy and I hope you get some use out of the methods too.
Glad to hear Brian; and yes - the main thing I got out of it is the ability to deselect all layers from script that I discovered by accident while writing these… It is not possible in Rhino 5 (added to V6 WIP as new method) but now with the un-parenting trcik can be done as well.