# Sort Points By X and Y Values

**URL:** <https://forum.dynamobim.com/t/sort-points-by-x-and-y-values/75711>\
**Category:** Lists-Logic\
**Tags:** revit, geometry, dynamo\
**Created:** [April 21, 2022, 6:48pm UTC](https://forum.dynamobim.com/t/sort-points-by-x-and-y-values/75711 "2022-04-21T18:48:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bayowindapo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bayowindapo/32/184532_2.png) [@bayowindapo](https://forum.dynamobim.com/u/bayowindapo)\
**Post date:** [April 21, 2022, 6:48pm UTC](https://forum.dynamobim.com/t/sort-points-by-x-and-y-values/75711/1 "2022-04-21T18:48:07Z")

</div>

Hi All

I have lists of points gotten from lines sorted by their angles.  
I am trying to get the points within these lists with the highest X or Y values. I cannot seem to work out the logic for doing so.  
The end goal is to use these points to define lines that I will use to dimension grids in plan views.  
The way I envision this working is that the maximum X values are given precedence, and if the points all have the same maximum X values, then the maximum Y values are used to sort the points. I hope this makes sense. Please see the diagram I have made to explain further. Also, find attached a Revit and .dyn file.  
Thanks for your help.  
[Sort Points by X and Y Values.rvt](https://forum.dynamobim.com/uploads/short-url/7babU3yhIQpkjzpYdvdAII9YOqu.rvt) (5.9 MB)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/5/a56b820ebbeb4a8009809cf821e7d71156d0d301.png)

[Sort Points by X and Y Values.dyn](https://forum.dynamobim.com/uploads/short-url/cc6Jr0EC1zs4m4a5ynXgxcAAlkf.dyn) (18.3 KB)

 ![Sort Points by X and Y Values_2022-04-21_08-22-05](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/a/aa91e1d63a68842c9eb98bc8d2de9a17978bf045.png)

@c.poupin @haganjake2

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [April 21, 2022, 6:55pm UTC](https://forum.dynamobim.com/t/sort-points-by-x-and-y-values/75711/2 "2022-04-21T18:55:03Z")

</div>

There are quite a few similar topics on the forum already. Give them a look and see how they’re using `SortByKey` to sort by both coordinate values individually. If you have any questions after that, let us know.

---

<div class="post-metadata">

**Author:** ![bayowindapo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bayowindapo/32/184532_2.png) [@bayowindapo](https://forum.dynamobim.com/u/bayowindapo)\
**Post date:** [April 21, 2022, 7:09pm UTC](https://forum.dynamobim.com/t/sort-points-by-x-and-y-values/75711/3 "2022-04-21T19:09:59Z")

</div>

Thanks for the response.  
I did look at those, but I guess not well enough.  
Will look again.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [April 21, 2022, 7:22pm UTC](https://forum.dynamobim.com/t/sort-points-by-x-and-y-values/75711/4 "2022-04-21T19:22:59Z")

</div>

If you can link some of the other posts and reference specific issues or questions you had we can get you some clearer answers.

---

<div class="post-metadata">

**Author:** ![stewart.skyler](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@stewart.skyler](https://forum.dynamobim.com/u/stewart.skyler)\
**Post date:** [April 21, 2022, 10:12pm UTC](https://forum.dynamobim.com/t/sort-points-by-x-and-y-values/75711/5 "2022-04-21T22:12:15Z")

</div>

Is this what you’re looking for?

 ![Sort Points by X and Y Values_2022-04-21_03-10-05](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/6/d66ab7f2e0c5ae1f812f696b1069590ce5a84fb6.png)

Edit: Ignore the values on the right most node, I had them sorting by X, swapped it for Y after I re-read your post and forgot to re-run it before taking the screenshot. Also there isn’t logic built into to check for matching x or y values in the lists…

---

<div class="post-metadata">

**Author:** ![stewart.skyler](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@stewart.skyler](https://forum.dynamobim.com/u/stewart.skyler)\
**Post date:** [April 21, 2022, 10:34pm UTC](https://forum.dynamobim.com/t/sort-points-by-x-and-y-values/75711/6 "2022-04-21T22:34:03Z")

</div>

Okay, spent a bit more time with it. I think this is what you were aiming for.

 ![Sort Points by X and Y Values_2022-04-21_03-33-45](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/6/26fafc96cdd617977562ea1936f2645f396b2079.png)  
[Sort Points by X and Y Values.dyn](https://forum.dynamobim.com/uploads/short-url/fdmr8ckcjNyMEgNtvp8LOCQOpQI.dyn) (47.7 KB)

---

<div class="post-metadata">

**Author:** ![bayowindapo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bayowindapo/32/184532_2.png) [@bayowindapo](https://forum.dynamobim.com/u/bayowindapo)\
**Post date:** [April 22, 2022, 7:44am UTC](https://forum.dynamobim.com/t/sort-points-by-x-and-y-values/75711/7 "2022-04-22T07:44:55Z")

</div>

Hi there thank so much.  
I will look through it and revert soon. Much appreciated.

---

<div class="post-metadata">

**Author:** ![bayowindapo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bayowindapo/32/184532_2.png) [@bayowindapo](https://forum.dynamobim.com/u/bayowindapo)\
**Post date:** [April 22, 2022, 8:43am UTC](https://forum.dynamobim.com/t/sort-points-by-x-and-y-values/75711/8 "2022-04-22T08:43:21Z")

</div>

Thanks for your help.  
This was pretty much what I needed. It just needed a little tweaking. I had to swop the true/false inputs at the if node and change the levels.  
I also sorted the input curves to have the same direction.  
See the .dyn file attached.  
Thanks again.

[Sort Points by X and Y Values.dyn](https://forum.dynamobim.com/uploads/short-url/B6FIPi6h3dcHw9qQCxDYFQ10Wh.dyn) (77.2 KB)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/6/46b77008c2a9724427e7b0e458094f30bb665102.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/3/136280b6541eee77b03e5424504d1a780391a343.png)
