|
-
Jul 2nd, 2007, 07:52 AM
#1
Thread Starter
Fanatic Member
sort hashtable
Hi,
I have populated a hashtable called CacheHashTableForwards.
This is how the hashtable gets populated:
CacheHashTablesForwards.Add(IndexName, code)
...
Now I would like to sort this data which is inside the Hashtable.
Not sure if this is a good approach but I use an ArrayList to do this as follows:
CacheHashTablesForwardsArraySorted = new ArrayList(CacheHashTablesForwards.Keys)
As you can see, The sorted array does not contains the other column, i.e. code
How can I properly sort using the arraylist.
Thanks
-
Jul 4th, 2007, 02:09 AM
#2
Re: sort hashtable
Why would you want to sort a Hashtable? The HashTable is basically a linked list. You should be able to access objects directly via the key object instead of any kind of iteration so I'm not sure why you would ever need to sort it. Maybe a HashTable is not the right tool for the job.
Please explain further.
-
Jul 4th, 2007, 07:38 AM
#3
Re: sort hashtable
If you want your collection sorted on the keys then a SortedList is preferable to a Hashtable. In .NET 2.0 you can use a generic SortedList or SortedDictionary.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|