In the case of strings and numbers, I'd recommend using leg instead of
cmp - that is, coerce both items to strings, then compare the strings.
But as far as cmp goes, "3 cmp '3'" should fail because a number
isn't a string.
--
Jonathan "Dataweaver" Lang
On 2009-Mar-26, at 10:50 pm, Patrick R. Michaud wrote:
But what to do with something like C< 3 cmp '3' >, or any
infix: where the operands are of differing types? Do we
constrain C to only work on similarly-typed operands (in which
case my sort above would fail), or am I overlooking somethi
Rakudo gives some strange results when sorting a list
of mixed strings and numbers, which leads me to look
for some clarification on infix: (which S03:2866 says
that sort uses by default). Here's the case I found
in Rakudo:
> say ('a', 1, 'b', 2 , 'c', 3, 'd', 4).sort.perl;
["a", "b", "c", 1