Sorting points (by X and Y or natural)

Hey guys ,

Im trying to sort some points by X en Y. I saw that the “sort natural” node automatically looks at both and then sorts them. Works perfectly , I thought, but then I found out that it doesnt handle negative numbers well.

The problem if I would first sort by X and then Y is that, if for example the y values are the same ,if I sort by X it sorts it but then if I sort by Y afterwords it rearranges the list eventhough every value is the same. Do you guys have an idea for how to solve this ?

I dont completly understand your question, are you trying to achieve this? :

Thank you for the reaction.

No, I dont want to achieve that.

I have multiple points where x is the same and y is not. Sometimes y is the same and X is not.

eg:
x = 1, y = 10
x = 1, y = 12
x = 1, y = 11
AND
x = 3, y = 11
x = 2, y =11

I want these points sorted like this:
x = 1, y = 10
x = 1, y = 11
x = 1, y = 12
x = 2, y = 11
x = 3, y =11

OR like this:

x = 1, y = 10
x = 1, y = 11
x = 2, y = 11
x = 3, y = 11
x = 1, y = 12

The problem is, I do not know if the X is the same or the Y the same. So i can not just use a sort by key and use x , or sort by key and use Y.

The sort natural node works perfectly on the above situation, but when an X or Y are below 0 , -4 for example , it does not see the “-” .

I am going to try a sort with if x=x , sort by y and if y=y sort by x , but when the x or y values are not the same (sometimes its a couple of mm different) then it wont work I think…

Update:
Solved the problem with the above method guys. Thanx for the reaction. The only thing is that either the x’s or y’s have to be the same. For the projects im doing thats oke.

Here you go:

You can swap the Point.X and Point.Y node around to sort the other option you explained :slight_smile:

6 Likes

Nice! That would work!

I already did the other method, because i think it would be a bit more work keeping track of groups/lists/sublists seeing that im working in large projects where there are 200+ locations that are already grouped per element/object.

Good! If your question is answered please mark your thread as solved.

Done (y)

1 Like