how to sort a hashtable?

  • Thread starter Thread starter Alexander Widera
  • Start date Start date
A

Alexander Widera

hi,

i have a self-made class (i call it mylist) which implements IEnumerable and
ICollection. In this class is a hashtable of an other self-made class (i
call it mydata).
mydata implements IComparable and overrides CompareTo like this:

public int CompareTo(Object obj)
{
if(obj is MyData)
{
MyData objData = (MyData)obj;
return(_Name.CompareTo(objData.Name));
}
return 0;
}


How can I sort "mylist"?

Thank You for your help.

Alex
 
I tried already:

public ICollection Sort()
{
ArrayList sorter = new ArrayList();
sorter.AddRange(_myData);
sorter.Sort();
return sorter;
}

But I get the error "System.ArgumentException: At least one object must
implement IComparable."

What is the problem? Is there an other way to sort?

Thanks,

Alex
 
Back
Top