Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Urgent!! How to sort an ArrayList of HashtableSorting

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic