i'm trying to make an IComparer that will sort numbers in ascending order with the exception that any negative values (in my case, all -1's) will sort to the end. the sequence would be 0, 1, 2, 3, -1, -1, -1... but i'm wasting all dam day and getting nowhere
i only have 4 numbers so far, -1, -1, 0, 1 and i cant even get that sorted correctly without sorting twice
public class DisplayOrderSorter : IComparer<AdHocColumn>
{
public int Compare(Column col1, Column col2)
{
if (col1.DisplayOrder == col2.DisplayOrder)
return 0;
else if (col1.DisplayOrder < 0 || col1.DisplayOrder > col2.DisplayOrder)
return 1;
else //if (col1.DisplayOrder < col2.DisplayOrder)
return -1;
}
}
that's the version of my icomparer that i'm on at the moment. anyone see what i'm doing wrong, besides maybe not sleeping enough... ?