in reply to Re^2: Argument isn't numeric in sort -- resolve or ignore?
in thread Argument isn't numeric in sort -- resolve or ignore?
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Argument isn't numeric in sort -- resolve or ignore?
by Argel (Prior) on Feb 26, 2016 at 12:05 UTC | |
by davido (Cardinal) on Feb 26, 2016 at 16:00 UTC | |
by Argel (Prior) on Feb 26, 2016 at 18:28 UTC |