... using System.Collections; using System.Collections.Generic; ... public class DecendingDateCompare : System.Collections.Generic.IComparer<DateTime> { public int Compare(DateTime x, DateTime y) { return x.CompareTo(y) * -1; } }A sample code to test:
... using System.Collections; using System.Collections.Generic; ... SortedList<DateTime, int> aSortedList = new SortedList<DateTime, int>(new DecendingDateCompare()); aSortedList.Add(DateTime.Now.AddDays(-10), 100); aSortedList.Add(DateTime.Now.AddDays(10), 10); aSortedList.Add(DateTime.Now.AddDays(-5), 90); aSortedList.Add(DateTime.Now.AddDays(5), 20); aSortedList.Add(DateTime.Now.AddDays(-3), 80); aSortedList.Add(DateTime.Now.AddDays(3), 30); StringBuilder sb = new StringBuilder(); IDictionaryEnumerator iDicEnum = (IDictionaryEnumerator) aSortedList.GetEnumerator(); while( iDicEnum.MoveNext() ) sb.AppendLine( iDicEnum.Key.ToString() + ", " + iDicEnum.Value.ToString() ); MessageBox.Show(sb.ToString());>Hi,