public class Negater<T> : System.Collections.Generic.IComparer<T> { private IComparer<T> comparer; public Negater(IComparer<T> comparer) { this.comparer = comparer; } public int Compare(T x, T y) { return this.comparer.Compare(y, x); // 反転する } }
List<MyClass> list = new List<MyClass>(); list.Sort(new Negater<MyClass>(new MyClassComparer()));
あれー,これネゲータじゃないか? 論理値を反転するのがネゲータだったかも.