public class MyComparer : IComparer { public int? LowerBound; public void Reset() { LowerBound = null; } public int Compare(int x, int y) { if (y >= x) { if (LowerBound == null ||LowerBound > y) { LowerBound = y; } } return (x < y ? -1 : x == y ? 0 : 1); } }