by default when you add an element to SortedList it's added in ascending order, for descending for you have to use a small trick.
internal class DescendingComparer : IComparer
{
public int Compare(object x, object y)
{
try
{
return System.Convert.ToInt32(x).CompareTo(System.Convert.ToInt32(y)) * -1;
}
catch (Exception ex)
{
return x.ToString().CompareTo(y.ToString());
}
}
}
SortedList membersList = new SortedList(new DescendingComparer());
membersList.Add()
Friday, February 15, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment