Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Urgent!! How to sort an ArrayList of HashtableSorting

 
padmaja mandava
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
padmaja mandava
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic