sort
FEEL built-in function · FEEL list functions
sort(list, precedes)
Returns the list sorted by the precedes function.
The precedes function decides the order: it receives two elements and returns true if the first belongs before the second. To sort contexts, compare the field you want. To sort in descending order, use >.
DMN 1.6 lists both parameters without marking precedes optional. The engine behind this site also accepts sort(list) for comparable elements and sorts them ascending, but a portable model passes the function.
Parameters
| Parameter | Type | Description |
|---|---|---|
| list | list | the list to sort |
| precedes | function | ordering function taking two elements and returning true if the first sorts before the second |
Examples
sort([3, 1, 2], function(x, y) x < y)
sort(["b", "a", "c"], function(x, y) x < y)
Edge cases and null handling
sort([{n: "b"}, {n: "a"}], function(x, y) x.n < y.n)
Sort contexts by a field.
Part of FEEL list functions: how positions, nulls and single values behave across all of them, aggregating over lists of contexts, and every function side by side.
Related functions
Defined by the OMG DMN 1.6 specification, chapter 10.3.4 (built-in functions).