Skip to main content
Sorts a list, optionally by a named property of each element.

Sort order

Pass "ascending" or "descending" on the sort_order port. Any other value (or no value at all) defaults to ascending.

Sorting by property

When the property port is connected, the node sorts elements using Map.get(element, property) as the key. This works for any element that responds to Map.get/2 (maps and structs). Lists of Date values are always sorted with a date-aware comparator regardless of the property setting.

Validation

The input value must be a list. Non-list inputs raise an error. The property and sort_order ports must each be a single value if connected.

Ports