public int CompareTo(SegPoint other) { int res = pt.CompareTo(other.pt); if (res != 0) { return(res); } if (!isLeft) { return(other.isLeft ? -1 : 0); } if (!other.isLeft) { return(1); } return(otherPoint.pt.CompareTo(other.otherPoint.pt)); }