in reply to Do the Schwartzian boogy!

you can forget about the ST!
use Sort::Key qw(nkeysort); my @sorted = nkeysort { $_->[1] } @AoA;
Sort::Key is much faster than the ST or even than the GRT and also easier to use... though still beta.

Replies are listed 'Best First'.
Re^2: Do the Schwartzian boogy!
by wazoox (Prior) on May 30, 2005 at 10:17 UTC
    Well done, Salva! How does it work? XS is quite beyond my abilities right now...
      it is more or less equivalent to:
      sub keysort (&@) { my ($keygen, @values) = @_; my @keys = map { &$keygen() } @values; my @ix = sort { $keys[$a] cmp $keys[$b] } 0..$#keys; @values[@ix]; }
      but implemented in C so there is no performance penalty because of the sort whith a custom comparison body (the heavy part of the alghorithm, with O(NlogN) cost).

      It also uses native C types to represent the keys when those are numbers, and tries to move or copy data around as less as possible.