C# Generic Lambda Comparer
public class LambdaComparer<T> : IComparer<T> { public enum Direction { Asc = 1, Desc = -1 } private readonly Comparison<T> _comparison; public LambdaComparer(Comparison<T> comparison) { _comparison = comparison; } int IComparer<T>.Compare(T x, T y) { return _comparison(x, y); } public static LambdaComparer<T> IgnoreSortComparer() { return IgnoreSortComparer(Direction.Asc); } public static LambdaComparer<T> IgnoreSortComparer(Direction direction) { return new LambdaComparer<T>((x, y) => x.Equals(y) ? 0 : ( int )direction); } } public class Data { public int X; public int Y; } [Test] public void TestLambdaComparer() { var data = new Data[] { new Data() { X = 1, Y = 1 }, new Data() { X = 3, Y = 2 }, new Data() { X = 5, Y = 3 }, new Data() { X = 2, Y = 4 }, new Data() { X = 4, Y = 5 } }; Console.WriteLine(...