in reply to Notation of sort function
Note in particular this fragment from near the end of the docs for sort:
The comparison function is required to behave. If it returns inconsistent results (sometimes saying $x[1] is less than $x[2] and sometimes saying the opposite, for example) the results are not well-defined.
"Consistent" means, for example, that if your comparison function says A > B, then it should also say B < A if called with the arguments the other way round. A comparator that specifies something different for $a than for $b will almost certainly not be consistent, and should be avoided.
As others have noted, the apparent redundancy stems from having the most general possible form of comparator - a piece of code that does the comparison. Some of the standard special forms such as the Schwartzian Transform (ST) and the Guttman-Rosler Transform (GRT) also have the side effect of reducing the redundancy. For more information on those see the excellent set of links at 11135952 provided by eyepopslikeamosquito.
|
|---|