Generic List Class Sort Method

public void Sort(Comparison<T> comparison)
http://msdn.microsoft.com/en-us/library/w56d4y5z.aspx

List<Person> pList = new List<Person>();
pList.Sort(ComparePersonByID); // pList를 ID로 정렬하기

[…]
public class Person : IComparable<Person>
{
    public static Comparison<Person> ComparePersonByID =
        delegate(Person p1, Person p2)      
        {
             return p1.ID.CompareTo(p2.ID);        
        };

[…]
}

Leave a Reply

Your email address will not be published. Required fields are marked *