On 2008-Dec-14, at 11:21 am, Moritz Lenz wrote:
Uri Guttman wrote:

how is sort ordering specified?
Currently it is not specified, it defaults to infix:<cmp>. If you can suggest a non-confusing way to specify both a transformation closure and a comparison method, please go ahead.

how does it know to do string vs numeric sorting?
infix:<cmp> does numeric comparison if both operands are numbers, and string comparison otherwise.

"Cmp" (like "eqv") depends on the particular type, so to sort a certain way, you should need only to coerce the values to the right type:

        @stuff.sort { .Num }         # numerically
        @stuff.sort { ~ .name.uc }   # stringwise
        @stuff.sort { Foo(%x{$_}) }  # foo-wise


I don't know what cmp returns for two values of different types. (Failure?)


-David

Reply via email to