hi, can anyone tell me how to sort records in a hashmap based on its keys?
Printable View
hi, can anyone tell me how to sort records in a hashmap based on its keys?
TreeMap map = new TreeMap(hashMap) takes care or ordering process:D
Sorting can be done by placing the hash map on to o tree map (TreeMap is sorted by nature)
Map myMap = new HashMap();
// put keys and values........
Map sortedMap = new TreeMap(myMap);