let dict: [String:Int] = [\"apple\":5, \"pear\":9, \"grape\":1]
How do you sort the dictionary based on the Int value so that the outp
Int
Dictionaries can't be sorted. Generally, when I need things sorted from a dictionary, I will make a separate array of my dictionary keys.
In your case, make an array of the keys, sort them by comparing their values in the dictionary.