Open jiahao opened 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:
AxisArrays
sort
sort!
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.
A[1] == A[:b] == 0
A[2] == A[:a] == 1
Do you mean A[1] == A[:b] == 0 and A[2] == A[:a] == 1?
Oops, indeed - corrected
I was trying to use
AxisArrays
to tabulate counts of categories and was surprised thatsort
andsort!
do not also sort the axis labels:What I would have expected was that after sorting,
A[1] == A[:b] == 0
andA[2] == A[:a] == 1
.