Map<String, object> set = new TreeMap<String, object>(); put names as key and values as value. it will automatically sort the names and values. [ October 29, 2007: Message edited by: satyabrat mishra ]
certification is not the proof of knowledge.......
If you need to retrieve values by key and iterate them in sequence, you may have to use two collections. You can get the values as a set and make a TreeSet. That will not only sort them, but will also remove duplicates, which may or may not be a good thing.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
To be clear, Jesper is talking about sorting by the key, and Stan is apparently talking about sorting by value. It's not immediately clear which is desired here, although I think sorting by key is more common. If you want to sort values without eliminating duplicates, don't put them in a Set - just use toArray() and then use Arrays.sort(). [ October 29, 2007: Message edited by: Jim Yingst ]