andyferris / Dictionaries.jl

An alternative interface for dictionaries in Julia, for improved productivity and performance
Other
282 stars 28 forks source link

Sorting by indices #109

Closed theogf closed 2 years ago

theogf commented 2 years ago

I am not sure if this is an expected behavior but when sorting keys, I get:

julia> d = Dictionary(3:-1:1, rand(3))
3-element Dictionary{Int64, Float64}
 3 │ 0.28031991092763076
 2 │ 0.17895610973159515
 1 │ 0.7416798710071865

julia> sort!(keys(d))
3-element Indices{Int64}
 1
 2
 3

julia> d
3-element Dictionary{Int64, Float64}
 1 │ 0.28031991092763076
 2 │ 0.17895610973159515
 3 │ 0.7416798710071865

If this is the expected behavior, how would you go about sorting a Dictionary according to its keys?

theogf commented 2 years ago

Of course, after writing this issue I notice the sortkeys function....