When using linq and you have
c.Sort()
Is there any good inline way of defining a Comparison
and/or IComparer
class w
If the objects in the List c already implement IComparable you wont need another one. But if you need custom comparison, you can implement IComparer in a nested class. You also can use a lambda expression to create a Comparison method on the fly:
persons.Sort( (person1, person2) => person1.Age.CompareTo( person2.Age ) );