When using linq and you have
c.Sort()
Is there any good inline way of defining a Comparison
and/or IComparer
class w
I have a ProjectionComparer
class in MiscUtil, so you can do:
IComparer comparer = ProjectionComparer.Create(x => x.Name);
c.Sort(comparer);
The code is also in this answer.
You can create a Comparison
instance directly with a lambda expression too, but I don't generally like the duplication that involves. Having said which, it often ends up being somewhat shorter...
EDIT: As noted, as of .NET 4.5, use Comparer