I have a HashMap defined as follows
Map<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
I am then storing data from databse in this hashmap and displaying the contents as follows on the console where entries towards the left of ---> are ID's and entries towards right are tags used by this ID
165767--->[dual-boot, windows, uninstall, ati, graphics, multiple-monitors]
6873 --->[kubuntu, re-installation]
34228--->[11.10, unity, launcher, libreoffice, icons]
I want to sort the ID's in descending order based on the number of tags that they have used i.e. based on map.get(key).size() so that the output should be ID 165767 followed by 34228 and then 6873 and so on.
I tried doing it with TreeMap but I am not able to figure out how to do it based on size and not the value of key and that too in descending order.