Sorting based on x and y coordinates consecutively

Hi there,

I have been trying to sort some curves based on their center point’s x, y and z coordinates, so far I only managed to do so for all three of them separately, the thing is that I want to do the x and y one to work consecutively in a way that for example I have my curves sorted based on y and then have those sorted based on x so I can go through the list one by one, one curve next to another and then repeat the same for curves with different z. Does anyone know how to proceed? I am probably stuck on something that either makes no sense or I am making it too complicated, so any kind of answer to release me from testing this would be appreciated!

I attached a .GH file and internalized the curves. Also highlighted my problem in the script.

Thanks for helping in advance!
test-aptRatio.gh (20.1 KB)


test-aptRatio_re.gh (10.8 KB)
This is working with the assumption that the coordinates of the points used are “clean”.
If such is risky, some rounding would helps.

Also, to change the order of X,Y,Z use a path mapper after the last Partition List component.
2021-09-02 18_53_06-Grasshopper - test-aptRatio_re_

3 Likes

You can also increase the weight of Y coordinates of your points by applying a factor.



SortPoints.gh (6.9 KB)

4 Likes

Thank you all for your replies! @maje90 @Mahdiyar , Both solutions work!