aspose file tools*
The moose likes Java in General and the fly likes Urgent!! How to sort an ArrayList of HashtableSorting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Urgent!! How to sort an ArrayList of HashtableSorting" Watch "Urgent!! How to sort an ArrayList of HashtableSorting" New topic
Author

Urgent!! How to sort an ArrayList of HashtableSorting

padmaja mandava
Greenhorn

Joined: Mar 01, 2001
Posts: 9
Hai,

I am stick with one problem i.e how to sort an Arraylist of Hashtables. If any body had any idea please let me know
Thanks in Advance
Padmaja.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Probably you need to give some more info on what you are trying to do. If there are two Hashtables in an array, how do we tell which one should go first? The one with the most elements? The one whose key comes first if sorted in alphabetical order? Should entries from different hashtables be kept in their original hashtables, or merged together while sorting? There are too many possiblilities here.


"I'm not back." - Bill Harding, Twister
padmaja mandava
Greenhorn

Joined: Mar 01, 2001
Posts: 9
Hai Jim,
I need to sort an ArrayList of Hashtables. Arraylist contains 100 hashtable entries where there are 4 elements in a hashtable. All the hashtables contains the same number of elemnts. I need to be sorted by first element in the hashtable
which is numeric. The results should be kept in the hashtables itself. I think i answered your question. If any questions please let me know.
Thanks
Padmaja
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Unfortunately, a hashtable doesn't have a "first element". It doesn't matter what order you added the elements to the hashtable; no particular internal order in guaranteed for the hashtable. If order is important, you can't use a hashtable.
Why don't you show an example of the data in one complete hashtable, and which part of that data is the "first element" you wich to sort with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Urgent!! How to sort an ArrayList of HashtableSorting