views:

695

answers:

2

I was asked by an employer to sort a hash table. I always thought that the usage of a hash table was in a way non-sort friendly. Am I wrong in thinking this, and if not can you point me to a good VB.Net(Yes Kill me now, but it's an old system) method of sorting a hash table.

Thanks.

+4  A: 

I have had several cases where I read name-value pairs from a file, need to keep them in the order they were listed in the file, but also need to O(1) lookup times. A sorted hashtable is how I accomplish both.

For .NET 1.1, use System.Collections.SortedList. For .NET 2.0+, use System.Collections.Generic.SortedDictionary.

DocMax
A: 
Adam Bernier