I have a Hashmap that links a zipcodes stored as keys and population stored as values in a hashmap.
The hashmap contains around 33k entries.
I\'m trying to get t
public class CheckHighiestValue { public static void main(String... s) {
HashMap map = new HashMap();
map.put("first", 10000);
map.put("second", 20000);
map.put("third", 300);
map.put("fourth", 800012);
map.put("fifth", 5000);
map.put("sixth", 30012);
map.put("seventh", 1234);
map.put("eighth", 45321);
map.put("nineth", 5678);
Set> set = map.entrySet();
List> list = new ArrayList>(
set);
Collections.sort(list, new Comparator>() {
@Override
public int compare(Entry o1,
Entry o2) {
return o2.getValue().compareTo(o1.getValue());
}
});
System.out.println(list.subList(0, 5));
}
}