Values(dict) returns key-value pairs after sorting

Heya,

by collecting a Dict, you turn it into a vector of Pairs. 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 Pairs 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

  1. turn the dict into a vector (of pairs)
  2. sort that vector according to your wishes
  3. extract the first and second component of your Pair
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.