Sort with comparator
Sort objects by key property
Here is an example of using the |sort filter with arrow functions to create custom sorting rules.
-
start: set: example_data@json: [ {"name": "Item 1", "key": "ZZZ"}, {"name": "Item 2", "key": "MMM"}, {"name": "Item 3", "key": "AAA"} ] return: sorted: {{example_data|sort((a,b)=> a.key<=>b.key)|column('name')|join(', ')}}
-
__return: sorted: Item 3, Item 2, Item 1