dcsimg
How to sort the Elements of a hashtable.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Krishna_Bhamidi
Posted On:   Tuesday, July 31, 2001 08:10 AM

Hi,

I have a set of key-value pairs that I store in a hashtable.

I want to sort the hashtable in order of the elements while retaining the key-value pair relationship. Any collections class I can use to do it?

Thankyou
Krishna.

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.

Re: How to sort the Elements of a hashtable.

Posted By:   AlessandroA_Garbagnati  
Posted On:   Tuesday, July 31, 2001 08:14 AM

Hi,

Check this forum thread out.
About | Sitemap | Contact