GrandFather did a better job of explaining it than I did.
sort expects the comparator subroutine to return a value less than zero, equal to zero, or greater than zero for the conditions of left < right, left == right, and left > right. So the use of cmp and <=> is commonplace. But some of the possible return values of the OP's comparator are strings, which will probably not be of much use to sort. It seems as though the OP thinks he should return the value that has higher precedence in the comparison, which is a fallacy, and except for unusual circumstances, indicative of a bug in the code.
Dave
In reply to Re^3: Argument isn't numeric in sort -- resolve or ignore?
by davido
in thread Argument isn't numeric in sort -- resolve or ignore?
by Argel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |