I want to write a comparator that will let me sort a TreeMap by value instead of the default natural ordering.
I tried something like this, but can\'t find out what
A TreeMap is always sorted by the keys, anything else is impossible. A Comparator merely allows you to control how the keys are sorted.
TreeMap
Comparator
If you want the sorted values, you have to extract them into a List and sort that.
List