Alternatively, there is the SortedList class which is a hybrid between
the Hashtable and ArrayList. (it sorts based on the key)
Although, it sounds as if your Hashtable stores the Person objects as
the value in which case this wouldn't work.
Nonetheless, now you know there's a SortedList. :)
On Fri, 9 Jan 2004 22:33:31 -0000, Jon Skeet [C# MVP]
<sk***@pobox.com> wrote:
Arjen <bo*****@hotmail.com> wrote: Let's say that we have a hashtable with some person objects.
This persons have a name.
Now I want to sort the people objects inside the hashtable by name.
How can the hashtable do this for me?
You can't - a hashtable is effectively a set, not a sequence: it
doesn't have an order.
What you *can* do is:
ArrayList al = new ArrayList (hashtable.Values);
al.Sort (myNameComparator);