Grouping the list

I think this will help you as well:
https://forum.dynamobim.com/t/sorting-list-based-on-several-variables/21005/5?u=paultus
It might be worth going through more than just that solution.