The problem is that your operator does not define a strict weak order . Think about how your example of {1,2}
and {2,1}
will go down in your statement. Suppose X = {1,2}
and Y = {2,1}
.
Is X <Y? Is 1 <2 and 2, 1? No, therefore X is not less than Y.
Is Y <x? Is 2 <1 and 1 <2? No, therefore Y is not less than X.
So, if X is not less than Y and Y is not less than X, what remains? They are equal.
You need to choose one of the members of your structure, either a
or b
, to be the main mapping. If the primary comparison leads to equality, then only you check the secondary comparison. Just as if you are in alphabetical order . First you check the first letter, and only if they are equal, you go to the next. An example of this is Hans Passant.
Here's a more serious example of a problem for your carrier. The one I gave above is not necessarily bad, because maybe you want {1,2}
be considered equal to {2,1}
. The main problem of crops with a set of such values: consider X = {1,1}, Y = {1,2}, Z = {2,2}
With your operator, X is finally less than Z, because 1 is less than 2. But X comes out equal to Y, and Y comes out equal to Z. To adhere to a strict weak order, if X = Y, and Y = Z, then X must equal Z. But here this is not true.