-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
sort_by/2 support #2491
Comments
also, to note - this is contrary to this feature request: |
I support this idea. Is there any reason that |
I support this idea as well |
Me too |
I support proposed solution. |
it's good idea |
Note that currently the |
Would it make sense to have a |
could this way work in jq 1.6? |
Here is a filter for sorting by multiple criteria, where the direction (ASCENDING or DESCENDING) can be specified separately for each criterion. To avoid confusion, I've presented it as multisort_by/2 rather than sort_by/2, though it is similar to the suggestion made by @seanlvjie.
Example:
|
Feature Request
Problem
When you have a columns and want to sort by multiple columns in various orders - you will start chaining reverses
my jq sort_by is stable, but if i need to sort by descending - I have to do double reverse, which i dont like
In order to keep both city descending and person ascending, (but by city) - I feel like I need double reverse, so this api does not looks good, in terms of performance for advanced sorting.
Do you know any workaround, not using double reverse?
Proposed solution
Is it possible to add
sort_by/2
, to be used as follows:sort_by(.person, false) | sort_by(.city, true)
?Second parameter is boolean -
isDesc
, which means you want to sort in descending not in ascending orderIs there any chance, that it can it be supported like that?
Links
Stackoverflow question here, if something will change:
https://stackoverflow.com/questions/74058111/how-to-sort-by-in-descending-order-without-reverse-in-jq
The text was updated successfully, but these errors were encountered: