List Operations
Perform list operations: push, pop, insert, remove, slice, concat, sort, reverse, unique, and exclude.
What it does
List Operations reshapes a list: push, pop, get, set, insert, remove, clear, reverse, sort, slice, concatenate, dedupe, generate a range, or exclude values found in another list. Pick the task from the Operation dropdown and only the parameters that operation needs appear.
It accepts any array-like value: a generic List, a NumberArray, Vec2/Vec3 arrays, a ColorArray, an IntArray, a String, or a collection of points. The result comes back as the same kind that went in, so no conversion step is needed first.
When to use it
Growing or shrinking a list: Push, Pop, Insert, Remove, Clear
One value out of a list by position (Get), or finding one (Contains, IndexOf)
Reordering: Reverse, or Sort by value
A portion of a list (Slice), or two lists joined (Concat)
Removing duplicates (Unique), or one list's values removed from another (Exclude)
A fresh sequence of numbers from scratch: Range, with no input list
| Parameter | Type | Default |
|---|---|---|
list | OneOf([Collection, NumberArray, Vec2Array, Vec3Array, ColorArray, IntArray, String]) | — |
operation | String | "Length" |
item | Any | — |
index | Number | 0 |
sort_order | String | "Ascending" |
sort_by | String | "X" |
start | Number | 0 |
end | Number | -1 |
step | Number | 1 |
other | OneOf([Collection, NumberArray, Vec2Array, Vec3Array, ColorArray, IntArray]) | — |
position | String | "End" |
Gotchas
Start and Index accept negative numbers to count from the end, where -1 is the last element. End on Slice is exclusive, and -1 means through the end of the list rather than second to last.
Sort and Unique read points and geometry by their position attribute, not by the values a plain array would give. Sorting a point collection by Luminance sorts by colour, not by position.
Range does not read the List input. It builds a new NumberArray from Start, End and Step alone, and wiring the List pin has no effect on the result.
Step on Range must not be zero. A zero step is silently treated as 1 rather than producing an infinite list.
Worked example
Add a List Operations node and wire an array into List.
Set Operation to Sort, choose Ascending or Descending, and pick which component to sort by if the array holds vectors or colours.
Chain a second List Operations node set to Unique to drop duplicate values from the sorted result.
See also
Range · Filter · Flatten · Collections