It looks like you’re trying to partition/group your meshes by some property. If so, this script might inspire a solution (i.e. using the groupby function from itertools):
Edit: That said, here a quick script attacking the more immediate problem, and not using any fancy libraries:
220509_GroupByPartitionList_00.gh (26.5 KB)
