Uri Guttman wrote:
>>>>>> "p" == pugs-commits  <pugs-comm...@feather.perl6.nl> writes:
> 
>   p>  This document attempts to document the list of builtin functions in 
> Perl 6.
>   p>  It assumes familiarity with Perl 5 and prior synopses.
>   p> @@ -870,6 +870,10 @@
>   p>  comparisons. C<@by> differs from C<$by> in that each criterion is
>   p>  applied, in order, until a non-zero (tie) result is achieved.
>  
>   p> +If C<$by> is a code object of arity zero or one, it is applied on each 
> item
>   p> +of C<@values>, and C<@values> is sorted by comparing the result values 
> with
>   p> +C<< &infix:<cmp> >> (Schwartzian Transform).
>   p> +
> 
> the ST is a specific implementation of this optimization. the concept is
> caching key extractions and expressions so they become O(N) and not O(N
> log N) which saves tons of cpu in larger complex sorts. but how the
> caching is done is really independent of the sort API/signature. as
> perl6 synopses aren't supposed to discuss implementation (they are
> language specs) calling it the schwartzian transform is somewhat out of
> place. 

I agree. As I wrote in the commit message, "feel free to improve the
wording" - the specs are open for hacking, especially S29, which is in
"draft" status.

> and some other questions:
> 
> and how does that style handle multiple keys?

What do you mean? The comparison is carried out on the return values of
the closure.

> 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.

> damian's
> Perl6::Sort and my Sort::Maker address those issues but this SIG short cut
> doesn't (yet).
> 
> also Sort::Maker generates sorts in 4 styles which may be of use to any
> implementors of perl6's sort. and it has an old (prize winner at TPC4)
> article on this topic that may be of some interest. and it only won a
> technical award because damian withdrew as he was the winner the
> previous two years in a row! :)

I'll take a look.

Cheers,
Moritz

Reply via email to