Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the man page to note that the sort functions are stable #1527

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/content/3.manual/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1287,13 +1287,24 @@ sections:
`sort_by(foo)` compares two elements by comparing the result of
`foo` on each element.

In versions newer than jq 1.5, the sorting functions are stable,
so sorting by multiple criteria can be done by either providing an
array, or by piping a sort on the second criteria into a sort on
the first.

examples:
- program: 'sort'
input: '[8,3,null,6]'
output: ['[null,3,6,8]']
- program: 'sort_by(.foo)'
input: '[{"foo":4, "bar":10}, {"foo":3, "bar":100}, {"foo":2, "bar":1}]'
output: ['[{"foo":2, "bar":1}, {"foo":3, "bar":100}, {"foo":4, "bar":10}]']
- program: 'sort_by(.foo,.bar)'
input: '[{"foo":4, "bar":10}, {"foo":3, "bar":100}, {"foo":4, "bar":1}, {"foo":3, "bar":99}]'
output: '[{"foo":3, "bar":99}, {"foo":3, "bar":100}, {"foo":4, "bar":1}, {"foo":4, "bar":10}]'
- program: 'sort_by(.bar)|sort_by(.foo)'
input: '[{"foo":4, "bar":10}, {"foo":3, "bar":100}, {"foo":4, "bar":1}, {"foo":3, "bar":99}]'
output: '[{"foo":3, "bar":99}, {"foo":3, "bar":100}, {"foo":4, "bar":1}, {"foo":4, "bar":10}]'

- title: "`group_by(path_expression)`"
body: |
Expand Down