Re: How to sort the Elements of a hashtable.
Posted By:
kish_sharma
Posted On:
Friday, August 10, 2001 12:02 AM
I have a simple solution for sorting Hashtable at the frontend. Get the keys in a set and make a new instance of SortedSet. Then iterate it to get the values for the sorted keys.
SortedSet ss = new SortedSet(ht.keySet());
If you want the values to be displayed in a sorted order you have to get the data from database in a sorted order. Mind you database sorting is native to it.
If this is confusing put the values as keys in Hashtable.
Think before using collection objects other than Vector and Hashtable as they are not synchronized.