in reply to Perl 6 sorting (was: Re: Sort: By keys, values, and their returning values.)
in thread Sort: By keys, values, and their returning values.
Having Pair objects and a built-in Schwartzian transform makes sorting really simple and powerful
I hope you are not really using the Schwartzian transform in Rakudo as it is one of the worst ways to optimize a sort-by-generated-key operation!
Something as...
should perform much better when correctly implemented in a low level language, specially if you are able to use packed arrays to store @keys.@keys = map gen_key($_), @data; @sorted = @data[sort {$keys[$a] <=> $keys[$b]} 0..$#keys];
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl 6 sorting (was: Re: Sort: By keys, values, and their returning values.)
by moritz (Cardinal) on Nov 26, 2009 at 12:37 UTC |