My goal is to have is given a map of to return an ascending array/list of sorted key values. For example:
Input: the Map containing the following key/value entries separated by a space:
"Apple" 10
"Orange" 8
"Kiwi" 15
Output:
{Orange;Apple;Kiwi}
The only other approach I could think of was creating a Map<Integer,Set<String>>
and then sorting by the key which is fairly convoluted. I got this approach to work but it seems rather inefficient in terms of code and logic. Thanks so much!