node sort - blossommerz/locus-hub GitHub Wiki
< Previous: Shift | Next: Select Range >
Order items by a geometric key.
Category: Data | Add menu: Data > Sort
- Geometry (any): the list to sort.
- By (number, editable: default 0) - the sort key: 0 Area | 1 X | 2 Y | 3 Radius (distance from origin) | 4 Angle (about origin) | 5 Name.
- Descending (boolean): flip the order so the largest / last-by-key comes first.
- Geometry (any): the same items, reordered by the key.
Reorders a list by a measured property rather than by position - area, position (X or Y), distance from the origin, angle around it - or by name. Type the key's number into By; flip Descending to reverse the direction.
0 Area. Every contour's area added up, with the sign thrown away, so a region with a hole in it counts the hole's area on top rather than subtracting it. Sort by Area and a downstream Select Range can grab the three biggest faces, or drop the slivers off the bottom.
1 X. Left to right, by the item's measured point.
2 Y. The same, up the other axis.
3 Radius. The measured point's straight-line distance from the origin, so a scattered field comes out in rings, innermost first.
4 Angle. The measured point's angle about the origin. It runs from due right and wraps at due left, which is where a ring built this way starts and ends. Sorting by Angle is the quick way to put a scattered set of points or tiles into a clean go-around order before wiring them into a Region: Points or Place - the difference between a tidy ring and a tangle.
5 Name. The name a shape carries out of the model window, the one the Layers panel shows. Two things are worth knowing before you use it:
-
It reads numbers as numbers.
Cir2comes beforeCir10, not after it, which is what you want and not what a plain alphabetical sort would do. Case is ignored. - Items with no name go last, keeping the order they arrived in. Points and anything built in the node graph have no name, so they settle at the end as a block rather than being shuffled against each other.
Descending reverses the whole run, so on Name the unnamed block moves to the front.
X, Y, Radius and Angle do not use a bounding box, and not a true area centroid either. Each item is first reduced to one point: the average of its own defining points - every curve endpoint, plus any loose points, with an arc contributing its two end positions.
That is usually what you expect, and once it is not: a full circle is one closed arc whose start and end sit at the same place on the rim, so it reduces to a point on its rim rather than its center. Two concentric circles therefore do not tie, and a ring of circles sorts by where each one's rim point falls, not by where its center is.
< Previous: Shift | Next: Select Range >
- Reverse | Shift: the other list-order nodes
- Area: the measure behind the Area key
- Select Range: take the top-N after sorting
- Lists & collections: how a list travels one wire
