I have a dictionary of type [Int : String]
that I want to sort by the keys and then convert it into array. For example:
let dict : [Int : String] = [18 : "Maya", 13 : "Ori", 49 : "Mom", 21 : "Lital", 51 : "Dad"]
// After convertion:
// ["Ori", "Maya", "Lital", "Mom", "Dad"]
How do I do that?
I only know how to convert dict
into array by doing Array(dict.values)
, but it doesn't make that in the right order.
Thanks