-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorperformanceMust go fasterMust go fastersortingPut things in orderPut things in order
Description
Sorting custom arrays produces an output whose type depends on the dimension over which the array is sorted.
This only happens with sort
(not sort!
), and AbstractArray
s that are neither AbstractVector
s nor Array
s.
It was introduced by #12823 in 2015.
SparseMatrixCSC
is one of an unbounded set of examples where this could come up.
julia> using SparseArrays
julia> sort(sprand(5, 5, .1), dims=1)
5×5 reshape(::SparseVector{Float64, Int64}, 5, 5) with eltype Float64:
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.584141 0.0 0.0
0.725133 0.0 0.796382 0.0 0.542729
julia> sort(sprand(5, 5, .1), dims=2)
5×5 SparseMatrixCSC{Float64, Int64} with 4 stored entries:
⋅ ⋅ ⋅ 0.0 0.286694
⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 0.0 0.847355
⋅ ⋅ ⋅ ⋅ ⋅
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorperformanceMust go fasterMust go fastersortingPut things in orderPut things in order