Originally posted by Sonny Gill:
Answered here -
https://coderanch.com/t/401025/java/java/tree-map-doesnt-sort
Dhanya, If you are going to post a topic again in a different forum, It is better to delete the original topic. Cheers.
I have deleted the post from the beginner forum.
Here is the response posted there >
That looks like bad design - If the method accepted any Map, you could pass it a LinkedHashMap which maintains the insert order.
If you really must use a TreeMap, you could subclass TreeMap and make it do what you want it to do. But that would be even worse, because you are breaking the contract declared by TreeMap, which is to maintain keys in the sorted order.
--------------------------------------------------------------------------------
Posts: 825 | Registered: Feb 2002 | IP: Logged