>>>>> "p" == pugs-commits  <pugs-comm...@feather.perl6.nl> writes:

  p>  This document attempts to document the list of builtin functions in Perl 
  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 
  p> +of C<@values>, and C<@values> is sorted by comparing the result values 
  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. the ST caches the extracted keys in arrays but the GRT caches
them in a single byte string which can be even faster. all the api/sig
is doing is removing the redundant key extract code for both $a and $b.

so say that the sort sig is easier to use for simple sorts as you don't
need to express the extract code on $a/$b but it is implied to do it
given the sort code block.

and some other questions:

and how does that style handle multiple keys? how is sort ordering
specified? how does it know to do string vs numeric sorting? 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! :)



Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

Reply via email to