Heya,
by collect
ing a Dict
, you turn it into a vector of Pair
s. The default dict is inherently unordered and so sorting it does not make sense but sorting the collection makes sense.
In your second line, you assign a (sorted) vector of Pair
s to arbeit. We don’t usually consider a vector as having keys but for generality, we can think of the index of an element as its key (same as for the dict where we have dict[key] = value
we have vector[index] = value
). That’s why you get a range for the keys: it’s the indices, whereas the values are the actual pairs of the dict.
So anyway, to your question. You can either use a sorted Dict
(from DataStructures.jl
) or
- turn the dict into a vector (of pairs)
- sort that vector according to your wishes
- extract the
first
andsecond
component of yourPair
arbeit = Dict("Vollzeit" => length(vollzeit), "Teilzeit" => length(teilzeit), "Minijob" => length(minijob))
arbeit = sort(collect(arbeit), by = x -> x[2])
x = map(x -> x[1], arbeit)
y = map(x -> x[2], arbeit)
Note that it’s usually easier to help if your example is self-contained, e.g. by providing dummy values for vollzeit
etc. or the dictionary itself.