Closed
Description
?sortperm
says
The permutation is guaranteed to be stable even if the sorting algorithm is unstable, meaning that indices of equal elements appear in ascending order.
I am not sure if the algorithm in #773 is meant to be stable, but for StaticArrays v1.0.0,
julia> using StaticArrays
julia> v = [(9, 0.0), (9, 0.0), (9, 0.0), (9, 0.0),
(3, 0.6000000000000001), (3, 0.6000000000000001)]
6-element Array{Tuple{Int64,Float64},1}:
(9, 0.0)
(9, 0.0)
(9, 0.0)
(9, 0.0)
(3, 0.6000000000000001)
(3, 0.6000000000000001)
julia> sortperm(v; by = last, rev = true)
6-element Array{Int64,1}:
5
6
1
2
3
4
julia> sortperm(SVector(v...); by = last, rev = true)
6-element SArray{Tuple{6},Int64,1,6} with indices SOneTo(6):
5
6
2
3
1
4