public Map.Entry[] getSortedHashtableByValue(Hashtable h) { Set set = h.entrySet(); Map.Entry[] entries = (Map.Entry[]) set.toArray(new Map.Entry[set.size()]); Arrays.sort(entries, new Comparator() { public int compare(Object arg0, Object arg1) { int key1 = Integer.parseInt(((Map.Entry) arg0).getValue().toString()); int key2 = Integer.parseInt(((Map.Entry) arg1).getValue().toString()); if(key1 > key2){ return -1; }else{ return 1; } } }); return entries; } Map.Entry[] entries = getSortedHashtableByValue(caseHash); for(Map.Entry str : entries){ String key = str.getKey(); String value = str.getValue(); }