I have a hashmap, I wish to get an array of the keys in this hashmap, but I wish for the array to be sorted.
For instance if the map looks like this:
<"2",obj1>
<"4",obj2>
<"6",obj3>
<"10",obj4>
<"5",obj5>
<"1",obj6>
<"15",obj7>
<"3",obj8>
I want the array to be: ["1", "2", "3", "4", "5", "6", "10", "15"]
The faster the better. Is there a built in way to do this?
Update 1
When i am using TreeMap, keys are sorted in following order:
"1", "10", "2" and so on.
but i want them to be like: "1","2","3".. "10","15".