I am using SortedList to arrange arraylist records dynamically in sort order by datecolumn, but by default it is sorting in ascending
There is no way to instruct the SortedList to do sorting in descended order. You have to provide your own Comparer like this
class DescendedDateComparer : IComparer
{
public int Compare(DateTime x, DateTime y)
{
// use the default comparer to do the original comparison for datetimes
int ascendingResult = Comparer.Default.Compare(x, y);
// turn the result around
return 0 - ascendingResult;
}
}
static void Main(string[] args)
{
SortedList test = new SortedList(new DescendedDateComparer());
}