# Deconstructing points into their coordinates function

Hi ,

I am working on a python script to sort a list of points according to their coordinates and now I am struggelling to find a function to turn each of these points into a list of three items. Any suggestions pleas ??.

Hi Ghaith,

You have a lot of options for what youâ€™re trying to accomplish. The built-in nodes or a DS script might actually prove to be a simpler solution because Python would involve some function mapping or iterating through the list of points:

Many Thanksâ€¦I am working on a 2D sorting of a list of families according to their positions. My approach is to get a reference row and sort it using the X coordinates then get the columns by using the positions already sorted coordinates and sort the columns using the Y coordinates. The approach is computationally expansive. Does anyone know a simpler and faster approach to sort the list of elements from right to left and from top to bottom ??

The second approach it to add the coordinate so I have a single key list and this method only works when all the family instances are located on the same quarter of the coordinates.

Not sure I understood what youâ€™re trying to achieve.

See if this file helps: 20150722-1

It seems like SortByKey and GroupByKey should help solve your problem

Vikram is right. You could create list pairs of the family instance and its location point and use â€śSortByKeyâ€ť on them similar to this:

1 Like

Thanks alotâ€¦ these nodes are exactly what I was looking for though still a problem. After I have sorted the families according to the Y axis of the coordinates of the position points I wanted to Group all the family instances that have the same Y in groups. For that ease I have used the group component with a double functions like what Vikram suggested. It only gave me one single array that has all the arrays with the double items inside While it supposes to give me as many arrays as the (Y) values changes. I have solved it by just sorting the points and comparing the new points with the old ones in Python and call the families according to the new indecies arrangement. I am though curious of how this Grouping component preserves the Hierarchy of the lists. Any ideas ??!

1 Like

Even when I have the simple list The Grouping doesnâ€™t work properly. I have tried it and it separates the items in some groups still !. I have changed the unites and still the same problems. Any Suggestions ?

Hi Ghaith,

Itâ€™s very hard to group by a pointâ€™s coordinates because itâ€™s a floating point number ( or a double). You could try to temporarily round them up to an integer value and see if that helps.

1 Like

Thanks a lot Dimitar !..I didnâ€™t pay attention to the numbers I was trying to sort. Many thanks !