I want to sort the tree map based on the key where key is a variable,so sorting should be based on variable value, How can we achieve this? I want use in built sort method rathar implementing it through code, any reply with example is of great help.
Share
TreeMap(which implementsSortedMap) stores automatically the keys in the correct order:As Key-Type (in that case
Integer) you can use any class which implementsComparable(or you can provide aComparatorwhen creating theTreeMap)Edit: Okay, here is a suggestion how to re-map your map.