can this be true?:
MethodError: no method matching sort!(::Dict{Int64,String})
that seems to be basic thing, am I doing something wrong?
Regards,
Alar Aints,
can this be true?:
MethodError: no method matching sort!(::Dict{Int64,String})
that seems to be basic thing, am I doing something wrong?
Regards,
Alar Aints,
Dict
s are unordered, so you cannot sort them.
OrderedDicts are ordered, so you can sort them.
julia> using OrderedCollections
julia> d = OrderedDict(1 => :a, 4 => :b, 3 => :c, 2 => :d)
OrderedDict{Int64,Symbol} with 4 entries:
1 => :a
4 => :b
3 => :c
2 => :d
julia> sort!(d)
OrderedDict{Int64,Symbol} with 4 entries:
1 => :a
2 => :d
3 => :c
4 => :b
julia> d
OrderedDict{Int64,Symbol} with 4 entries:
1 => :a
2 => :d
3 => :c
4 => :b
Thanks, so how do I get it?
I typed:
using Pkg
Pkg.add(“OrderedCollections.jl”)
I got:
julia> Pkg.add(“OrderedCollections.jl”)
Cloning default registries into ~/.julia
Cloning registry from “GitHub - JuliaRegistries/General: The official registry of general Julia packages”
Added registry General
to ~/.julia/registries/General
ERROR: The following package names could not be resolved:
Please specify by known name=uuid
.
Try:
Pkg.add(“OrderedCollections”)
Thanks, works.