# Deconstructing points into their coordinates function

**URL:** <https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834>\
**Category:** Packages\
**Created:** [July 21, 2015, 12:56pm UTC](https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834 "2015-07-21T12:56:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ghaith\_Tish](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@Ghaith\_Tish](https://forum.dynamobim.com/u/Ghaith_Tish)\
**Post date:** [July 21, 2015, 12:56pm UTC](https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834/1 "2015-07-21T12:56:54Z")

</div>

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 ??.

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [July 21, 2015, 8:45pm UTC](https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834/2 "2015-07-21T20:45:25Z")

</div>

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:

![2015-07-22_10-05-47](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/0/080f965d80fa8391f0ef100c80d4f91c216cf74a.png)

---

<div class="post-metadata">

**Author:** ![Ghaith\_Tish](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@Ghaith\_Tish](https://forum.dynamobim.com/u/Ghaith_Tish)\
**Post date:** [July 21, 2015, 9:03pm UTC](https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834/3 "2015-07-21T21:03:10Z")

</div>

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 ??

---

<div class="post-metadata">

**Author:** ![Ghaith\_Tish](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@Ghaith\_Tish](https://forum.dynamobim.com/u/Ghaith_Tish)\
**Post date:** [July 21, 2015, 9:36pm UTC](https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834/4 "2015-07-21T21:36:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [July 21, 2015, 10:08pm UTC](https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834/5 "2015-07-21T22:08:08Z")

</div>

Not sure I understood what you’re trying to achieve.

See if this file helps: [20150722-1](http://dynamobim.com/wp-content/uploads/forum-assets/testingwaters/07/22/20150722-1.dyn)

It seems like _SortByKey_ and _GroupByKey_ should help solve your problem

![20150722-1](http://dynamobim.com/wp-content/uploads/forum-assets/testingwaters/07/22/20150722-1-600x294.jpg)

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [July 21, 2015, 10:26pm UTC](https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834/6 "2015-07-21T22:26:13Z")

</div>

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

![2015-07-22_11-48-07](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/5/50810e98527770c4f1708db702dfaf0d291e2570.png)

---

<div class="post-metadata">

**Author:** ![Ghaith\_Tish](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@Ghaith\_Tish](https://forum.dynamobim.com/u/Ghaith_Tish)\
**Post date:** [July 23, 2015, 12:30pm UTC](https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834/7 "2015-07-23T12:30:33Z")

</div>

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 ![question](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/1X/c7bdfb0bc488069a3daf1d2d16182ed43b0551d5.png) of the lists. Any ideas ??!

---

<div class="post-metadata">

**Author:** ![Ghaith\_Tish](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@Ghaith\_Tish](https://forum.dynamobim.com/u/Ghaith_Tish)\
**Post date:** [July 25, 2015, 6:47am UTC](https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834/8 "2015-07-25T06:47:49Z")

</div>

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 ? ![problem01](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/8/8c73a963ec3f828bae1ad253ff70eee1cc0ba013.png)

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [July 25, 2015, 11:22pm UTC](https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834/9 "2015-07-25T23:22:00Z")

</div>

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.

![2015-07-26_13-07-23](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/4/44ba333473c83e1fb2ef1de851b120cb132608f8.png)

---

<div class="post-metadata">

**Author:** ![Ghaith\_Tish](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@Ghaith\_Tish](https://forum.dynamobim.com/u/Ghaith_Tish)\
**Post date:** [July 26, 2015, 2:25am UTC](https://forum.dynamobim.com/t/deconstructing-points-into-their-coordinates-function/1834/10 "2015-07-26T02:25:43Z")

</div>

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