如T为
class student()
{
string name;
int age;
}
按age大小排序
写法一:
students.Sort((student1,student2)=>student1.age-student2.age);
写法二:
void SortStudents(List<student> students)
{
students.Sort(Comparison);
}
private int Comparison(student student1, student student2)
{
return student1.age - student2.age;
}