When you are writing a sort comparison function (say, to be passed to
or *gasp* to be used as
an ), your comparison function needs to follow
these rules:
Reflexivity:
.
Anti-Symmetry:
has the opposite sign of
, where 0 is considered to
be its own opposite.
Transitivity:
If
and ,
then .
Here are some logical consequences of these rules...