in reply to An APL trick for the Schwartzian Transform
Actually, if you’re at that point, you can make things a whole lot more efficient:
my @sorted = @unsorted[ do { my @cache = map key_from( $_ ), @unsorted; sort { $cache[$b] <=> $cache[$a] } 0 .. $#cache } ];
The Schwartzian Transform suffers severely from creating a huge number of tiny anonymous arrays. This form creates only one extra array and one extra list. The larger the array and the less expensive the key calculation routine, the larger the impact this will have.
Makeshifts last the longest.
|
|---|