add Order.rev() for reverse sorting #55891
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sorting with
by=x -> (x[1], x[2])
sorts byx[1]
and then (forx[1]
duplicates) byx[2]
.Then,
sort(X; by)
sorts in the ascending order ofx[1]
andx[2]
,sort(X; by, rev=true)
sorts in the descending order of both.But there's no way to sort in ascending order of
x[1]
and then descending order ofx[2]
. This PR makes it possible, withby=x -> (x[1], Order.rev(x[2])
.What do you think of this interface? I imagine this
Order.rev
function being public, but not exported.