in reply to RFC:A brief tutorial on Perl's native sorting facilities.
I think another good node about sorting is Better sorting than the ST (was: Perl is dying), I think this "trick" should be included in the tutorial as well.
As it doesn't create lots of tiny arrays it should even be quicker than ST. And it doesn't have the restrictions of GRT.{ my @keys = map {...} @list; my @idx = sort {$keys[$a] cmp $keys[$b]} (0..$#list); @list = @list[@idx]; } # or { my @keys = map {...} @list; @list = @list[ sort {$keys[$a] cmp $keys[$b]} (0..$#list) ]; }
In Section
Meditations