Sorting by location of sublist items

Hi All,
Trying to write a pile numbering tool. Each pilecap element has 4 nested families within it and i want to number each of those.
So far i have got all of the pilecaps and sorted them based on “y” location (as per pic)
Now i need to sort each of the “200dia” piles based on their “y” location, how would i do this sorting within the sublist?

Could you upload a dummy revit file so that other users can try and play around?
Anyways try to read the “List management” chapter here: and see if it helps, possibly feeding your last node"FamilyInstance.SubComponents" into a new Element.Location, Point.Y, List.SortByKey(changing its “levels” as shown in the link")

Hi GregX,
Thanks for your reply.
Dummy file attached.

Tried adding another sortbykey but it didnt work and gave an error.
Pile Naming.rvt (652 KB)

SortPiles.dyn (5.0 KB)

1 Like

Thanks Vikram but unfortunately I don’t think that is going to work for my situation.
As per my first image I need to sort the pilecap locations first an then once those are sorted just resort the piles within each cap. Once I have this I can then flatten the list to just rename the mark of the piles.

(Example, the top left pilecap should have piles numbered 1,2,3,4, then the next pilecap is 5,6,7,8)

1 Like

@Mike_Turpin This should work better
PileSort.dyn (9.4 KB)