hi, can anyone tell me how to sort records in a hashmap based on its keys?
This is a discussion on Sorting a hash map based on its keys within the Java forums, part of the Software Development category; hi, can anyone tell me how to sort records in a hashmap based on its keys?...
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
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);