Add support for built-in function 'sort, sort_by(path_expression)'
The sort functions sorts its input, which must be an array. Values are sorted in the following order:
null
false
true
numbers
strings, in alphabetical order (by unicode codepoint value)
arrays, in lexical order
objects
The ordering for objects is a little complex: first they鈥檙e compared by comparing their sets of keys (as arrays in sorted order), and if their keys are equal then the values are compared key by key.
sort may be used to sort by a particular field of an object, or by applying any jq filter.
sort_by(foo) compares two elements by comparing the result of foo on each element.
Here is a workaround
~
yq r --tojson input.yaml | jq . | yq r -
~
Unfortunately, using jq will remove comments. Can we re-open this issue ?
Most helpful comment
Unfortunately, using jq will remove comments. Can we re-open this issue ?