I've implemented this before a very long time ago and since I forgot, i read up about it again to see what the method should look like for CompareTo()
I have implemented this correctly but when I sort the ArrayList giving it null as a parameter, it seems not to sort it but do it in decending order.
So:
I have an arraylist of specific objects (note, this is not a general list....this is using .NET 1.1)
I have implemented the IComparable interface and its method for the object type in question.
I did an: collection.Sort(null); and it didnt seem to sort it (but it does call the compareTo() method):
Code:
#region IComparable Members
public int CompareTo(object obj)
{
// TODO: Add VacancyInfoHelper.CompareTo implementation
if ((obj is VacancyInfoHelper) == false)
{
return -1;
}
VacancyInfoHelper helper = (VacancyInfoHelper)obj;
return this.rank.CompareTo(helper.rank);
}
#endregion
edit: forgot to mention it is an ASP.NET application and since the private field "rank" is set to 0 by default, would that make much difference? I believe it is so how do I do sorting on an ASP.NET based application?
