TreeMap Sorting by Keys then Values
807580Dec 21 2009 — edited Dec 22 2009Is there anyway to sort a TreeMap via it's keys and values?
I have a TreeMap where keys are strings and values are integers. I wish to sort via the highest value, and then the key alphabetically.
For example,
treemap.put("test", 5);
treemap.put("hello", 5);
treemap.put("face", 1);
treemap.put("inout", 8);
How can I make the output
inout - 8
hello - 5
test - 5
face - 1
At the moment, it just sorts the keys alphabetically.