Builtin Library
README.md
elements.sort
Put the elements in the order of a per-element value, least first or greatest first, every column coming with its element; elements with the same value keep the order they had. Sorting points renumbers the corners that land on them; sorting faces moves each face's corners with it.
Built from the sort kernel over the key, attribute.carry of every column of the class, and, for faces, a second sort of the corners by their face's new place.
Inputs
geometry(Geometry). What is reordered. Nothing is added or dropped.key(Field | Float). Per element ofclass, the value it is ordered by.class(one of point, primitive). Default"point". Which elements are ordered.descending(Bool). Defaultfalse. Greatest first.
Outputs
geometry: the geometry with the elements ofclassin the new order.
Example
local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local sorted = g.elements.sort({ geometry = points, key = g.field.position().x, descending = true })
The points come out at x = 1.5, 0.5, -0.5, -1.5.