expr-lang/expr

Refactor `sort()` builtin to support predicates

Closed this issue · 2 comments

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')

But from a readbility point of view sortBy looks better. Let's keep both sort functions.

Done!

Now sortBy supports predicated: events | sortBy(.Date)