Redundant sort / sortperm options: why?

sort
sortperm

#1

sort and sortperm take a couple of keyword arguments that appear to be redundant (at least, one of them is a subset of the other): rev and order. That is:

julia> sortperm(a, rev=true) == sortperm(a, order=Base.Order.Reverse)
true

julia> sortperm(a) == sortperm(a, rev=true, order=Base.Order.Reverse)
true

Benchmarking suggests no advantage to one over the other.

Is the idea that a custom sorting algorithm (via order) can be automatically reversed with the rev keyword? If not, what is the purpose of having both rev and order?


#2

https://github.com/JuliaLang/julia/issues/22382#issuecomment-308732349, https://github.com/JuliaLang/julia/pull/22388 etc


#3

Ok. Sounds like Ordering is here to stay after reading the github issues.

I think it’s quite a bit more complicated than setting a rev = true/false. Would love a simple blog post to explain what all the Ordering options are about.