You are approaching it wrong. What you want is:
1) Get the entrySet()
from the Map
.
2) Sort the entries by their value
3) Print the key
of each sorted entry
What your program does is sort the key
s alphabetically. And it does it fine.
5
solved How do I sort my HashMap keys – they are not sorting? [closed]