Order Left to Right Top to Bottom

john's Avatar

john

11 Mar, 2022 02:51 AM

It is sometimes necessary to sort a set of points into a predictable LRTB (Left to Right, Top to Bottom) order.

The first time I had to do this I thought it was too unusual to merit inclusion in my Node Library. The second time I thought it was still more of a fluke than a regular thing. But the third time I finally decided to make an official Library Node.

order_LRTB takes a list of points and returns those same points in Left to Right, Top to Bottom order.

You would think you could do this by simply using a sort points node by X and a second one by Y, but the Y sort does not preserve the previous order for points with the same Y value.

The attached demo and screenshot show this. I take a 16-sided polygon - which creates points in clockwise order - and feed those points first into a X and Y sort, then into the order_LRTB node. I then divide the points into pairs and draw an arrow from the first point to the second. The X and Y points come out in Y order, but not consistently in an X order for each pair. The order_LRTB node sorts them correctly.

Not a big deal. But handy every now and then. Included in the next rev of my library COMING SOON!

John

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • order_LRTB_screenshot.png 289 KB
  • order_LRTB_demo.ndbx.zip 3.96 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

06 Sep, 2023 07:20 AM
05 Sep, 2023 08:40 PM
30 Aug, 2023 03:16 AM
19 Aug, 2023 03:22 AM
29 Jul, 2023 05:52 AM

 

28 Jul, 2023 10:53 PM
23 Jul, 2023 07:04 AM
14 Jul, 2023 03:05 AM
07 Jul, 2023 06:26 AM
05 Jul, 2023 11:44 PM
30 Jun, 2023 12:48 PM