Skip to main content

Iterator: Sort

Order a list by a comparable key derived per element. The sub-graph runs once per element and emits a Number or String on the auto-created Iterator::Collect's key connector. The original elements are then reordered by those keys.

A key that is neither a Number nor a String (or no key at all) is treated as missing — no error is raised. The comparator places numbers before strings and missing keys after everything; disabling Ascending reverses the whole comparator, so ascending order puts missing keys last and numbers before strings, while descending order puts missing keys first and strings before numbers.

Example
Input (ascending): [{name: "B", n: 2}, {name: "A", n: 1}]
Body: key = el.n
Output: [{name: "A", n: 1}, {name: "B", n: 2}]

Parameters

Ascending

Sort ascending when enabled (default), descending when disabled.

Input

Arrayrequired
List to sort (Array or JSON array).
Value

Optional value injected into every iteration as value on the entry node.

Output

Result
The reordered list.