How can I sort a treemap using its values rather than the key?
Swap values and keys.
More seriously, please provide some context what you want to achieve. Maybe it is enough to sort after other processing is finished.