public int Compare(GenericLookupResult x, GenericLookupResult y) { if (x == y) { return(0); } int codeX = x.ClassCode; int codeY = y.ClassCode; if (codeX == codeY) { Debug.Assert(x.GetType() == y.GetType()); int result = x.CompareToImpl(y, _comparer); // We did a reference equality check above so an "Equal" result is not expected Debug.Assert(result != 0); return(result); } else { Debug.Assert(x.GetType() != y.GetType()); return(codeX > codeY ? -1 : 1); } }