Refactor `sort()` builtin to support predicates
Closed this issue · 2 comments
antonmedv commented
Expr support two sort function right now: sort and sortBy.
- sort for []int or []string array
- sortBy for []map or []strict.
The sortBy takes string as a name of the field to sort. It will be cool to add support for predictates in sort.
array | sort(.Date, 'desc')
antonmedv commented
But from a readbility point of view sortBy
looks better. Let's keep both sort functions.
antonmedv commented
Done!
Now sortBy supports predicated: events | sortBy(.Date)