Hash table sorting?

  • Thread starter Thread starter john sutor
  • Start date Start date
John,

I don't know what you are trying to do. Are you trying to sort the keys
of the hashtable? If so, then this will be quite hard, unless all of the
keys are of one particular type. If they are, then you could use the Keys
property to get the keys. Once you have the ICollection interface
representing the keys, you can get an array of them by calling CopyTo.
Finally, you can pass that array to the static Sort method on the Array
class to sort it.

Hope this helps.
 
john sutor said:
Does anyone know how to sort a hash table?

Hashtables are inherently unsorted. What you could do is create an
arraylist:

ArrayList entries = new ArrayList(hashtable);

and then sort that list. Each entry in the list is a DictionaryEntry.
 
Back
Top