Im trying to sort a hashmap by length of the arraylists I have as the values. My hashmap is:
HashMap<Integer, ArrayList<Integer>> NameofMap = new HashMap<Integer, ArrayList<Integer>>();
I have been trying to use a comparator and collections.sort inline, but it doesnt seem happy with my onject types, and I can't figure out how to fix it. Any help would be greatly appreciated, my code so far is as follows:
Collections.sort(NameofMap.values(), new java.util.Comparator<ArrayList<Integer>>() {
@Override
public int compare(ArrayList<Integer> o1, ArrayList<Integer> o2) {
return o1.size().compareTo(o2.size());
}
});