# Sort sublists

**URL:** <https://forum.dynamobim.com/t/sort-sublists/58893>\
**Category:** Geometry\
**Created:** [January 3, 2021, 7:32pm UTC](https://forum.dynamobim.com/t/sort-sublists/58893 "2021-01-03T19:32:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dariusz.mordal](https://avatars.discourse-cdn.com/v4/letter/d/d78d45/32.png) [@dariusz.mordal](https://forum.dynamobim.com/u/dariusz.mordal)\
**Post date:** [January 3, 2021, 7:32pm UTC](https://forum.dynamobim.com/t/sort-sublists/58893/1 "2021-01-03T19:32:34Z")

</div>

Hi, I have a problem with sorting. I’ve divided points list to sublists by X and now I would like to sort all the points with same X by Y (and want to join them by line, so I need it to be in order).

All I can do is take one sublist at a time (python script just create a list from one sublist), then everything works like I want it to.

How would you solve this task?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/6/f6f60bde26f169dec4fbc5e48d79b993fa3f4aae.png)

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [January 3, 2021, 9:44pm UTC](https://forum.dynamobim.com/t/sort-sublists/58893/2 "2021-01-03T21:44:46Z")

</div>

Hi @dariusz.mordal,

You can use the node **List.GroupByKey** with the Points as List and their X-value (maybe do math.round) as Keys, this way each point is now grouped with other points with the same X-value, then you can sort those sublists by their Y-value, like this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/2/028b138b7ff7cfdb14ef03388f368817ade762b2.png)  
Ps: the list level (@L2) in the Sort.ByFunction node tells that node to do that function in the list of level 2, the lists which contain the individual points.

[2021-01-03 SortPointsByXThenY.dyn](https://forum.dynamobim.com/uploads/short-url/zvWxEpjhRpTQuJvVIopYP93bDAt.dyn) (17.1 KB)

---

<div class="post-metadata">

**Author:** ![Bjorn\_Keulemans1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bjorn_keulemans1/32/54676_2.png) [@Bjorn\_Keulemans1](https://forum.dynamobim.com/u/Bjorn_Keulemans1)\
**Post date:** [January 4, 2021, 7:58am UTC](https://forum.dynamobim.com/t/sort-sublists/58893/3 "2021-01-04T07:58:24Z")

</div>

And check your results, you might need to do some rounding on the X or Y values from the points to Group them together.
