Try the below code - it will give you a string array sorted using the compareTo method. If the key you are using is a different object type just do the same thing but make sure it implements the Comparable interface. I didn't compile this so you may need to tweak it to get rid of any compilation errors...
Code:Set keys = myMap.keySet(); String[] strkeys = keys.toArray(new String[keys.size()]); Arrays.sort(strkeys);




Reply With Quote