sort_by
arraySorts an array by specified key values
Syntax
sort_by(keys) Parameters
keys (string) One or more keys to sort by (e.g., .age, .name)
Returns
array A new array sorted by the specified keys
Examples
Input:
sort_by(.age) Output:
Sorts people by age field Input:
sort_by(.name, .age) Output:
Sorts by name, then age The sort_by() function sorts array elements by one or more specified key values. When multiple keys are provided, it sorts by the first key, then uses subsequent keys for tie-breaking.
Usage
This function is essential for sorting complex objects and data structures by specific fields, enabling multi-level sorting operations on CSV and JSON data.