JuliaArrays / AxisArrays.jl

Performant arrays where each dimension can have a named axis with values
http://JuliaArrays.github.io/AxisArrays.jl/latest/
Other
200 stars 41 forks source link

sort(::AxisArray) does not sort labels #172

Open jiahao opened 4 years ago

jiahao commented 4 years ago

I was trying to use AxisArrays to tabulate counts of categories and was surprised that sort and sort! do not also sort the axis labels:

julia> A = AxisArray([1, 0], Axis{:cat}([:a, :b]));

julia> A[:a], A[:b]
(1, 0)

julia> sort!(A);

julia> A[:a], A[:b]
(0, 1)

What I would have expected was that after sorting, A[1] == A[:b] == 0 and A[2] == A[:a] == 1.

iamed2 commented 4 years ago

Do you mean A[1] == A[:b] == 0 and A[2] == A[:a] == 1?

jiahao commented 4 years ago

Oops, indeed - corrected