Sorting Point Order

Hi,
Newbie here in Grasshopper. I want to ask for help on how can I sort this points in an order that is described in the image.

Any reply will be helpful. Thank you.

Building Modulation Study.gh (60.2 KB)

1. Deconstruct the points

Use Deconstruct Point

  • Input: your grid of points

  • Outputs: X, Y, Z


2. Sort all points by Y

Use Sort List

  • A → your points

  • K → the Y values from Deconstruct Point
    → Output: points ordered by rows (bottom → top)

This groups the points in row order.


3. Partition into rows

You need to tell Grasshopper how many points per row.

If your grid is 6 points per row → Partition List (Size = 6)
If it’s 5 points per row → Size = 5
(Use List Length Ă· number of rows if unsure)

Partition List takes the sorted-by-Y list and divides it into rows.


4. Sort each row by X

Add a Sort List inside the row loop:

  • A = row (from Partition List)

  • K = X (Deconstruct Point → X)

You’ll need to use Graft on the X list so each row sorts independently.

Now each row is sorted left → right.


5. Flatten

Flatten the final sorted rows → you now have the full correct order.

Thank you @GHwiz I will try this method.

FYI.
SortingPointOrder.gh (9.8 KB)

You can also use Sort Points:

and then use Tree Statistics to partition.

Sadly, Sort Points is susceptible to to rounding issues, and only sorts X->Y->Z, so to trick it into working you have to provide an expression as I did here:

* = {round(x.z,3),round(x.y,3),round(x.x,3)}

Here I have sorted with the distance but changed the data tree with flatten and flip matrix.

Building Modulation Study.gh (56.7 KB)

Thank you all for your help I tried all your solutions but what works best for the script is from @Volker_Rakow .. I want this panel numbers to stay in order no matter how many modules are in surface. This surface represents one face of elevation of a typical building. Thank you all for your help.

As happy as I am to have helped you, if you are simply dealing with the divisionings of a surface that lie in the UV directions of that surface, Jesse’s solution is probably the best way to go. This is because it creates geometry in correct order instead of forcing you to correct the order in afterward.

It also creates untrimmed surfaces.

Yes but currently I am still using Rhino 7. I believe “Transpose Surface” is only available in Rhino 8.

It is. However, needing to transpose the U and V directions sounds like the problem of a larger context. If it is just about the divisioning, you can switch the U and V divisioning orders and still come to the same result.

I’ll take note of this @Volker_Rakow .. There is still much to learn for me I guess.. :laughing: