How do you sort out a hash maps numerically and then alphabetically ? input:
anna , 1
jane , 2
amy , 3
required output:
amy , 3
anna , 1
jane , 2
Map<String, Integer> myDictionary = new HashMap<String, Integer>();
This is how i sort it out atm but it only sorts it alphabetically
Set<String> sorted = new TreeSet<String>();
sorted.addAll(myDictionary.keySet());
for(String key: sorted){
System.out.println(key + " -" + myDictionary.get(key));
}