I’m displaying a TreeMap sorted by keys currently by using Map.entrySet(). However, I want to display the contents sorted by both values and keys. Is this possible? How would I go about it if it were?
EDIT: Rephrasing:
I’m currently displaying a treemap sorted by keys. I want to display it sorted by values initially, but if the values are the same, I want the keys displayed in ascending order.
Use a Comparator to sort the Entry objects in your map.
Result: