AxisArrays.jl
AxisArrays.jl copied to clipboard
sort(::AxisArray) does not sort labels
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.
Do you mean A[1] == A[:b] == 0 and A[2] == A[:a] == 1?
Oops, indeed - corrected