AxisArrays.jl icon indicating copy to clipboard operation
AxisArrays.jl copied to clipboard

sort(::AxisArray) does not sort labels

Open jiahao opened this issue 5 years ago • 2 comments
trafficstars

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.

jiahao avatar Dec 11 '19 04:12 jiahao

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

iamed2 avatar Dec 11 '19 20:12 iamed2

Oops, indeed - corrected

jiahao avatar Dec 12 '19 01:12 jiahao