Sorting objects in a list by their XYZ location

Maybe a simple question but I have a script that takes a series of surfaces and labels them at their centroid. Works well, but I would like to sort the list by the XYZ coordinate of the centroid such that–no matter what order they are selected in–the leftmost, bottommost, etc will always be item “0”. I’m sure im missing something here, in grasshoppper its trivial to sort a key by a value.

Can anyone point me in the right direction?

many thanks

Are you working in python?

try rhinoscriptsyntax.SortPointList (points, tolerance=None)
or rhinoscriptsyntax.SortPoints (points, ascending=True, order=0)

HTH
-Willem

Yes! I am working in python and THANK YOU! This is just what i was looking for.

1 Like