in reply to Re: Do the Schwartzian boogy!
in thread Do the Schwartzian boogy!

Well done, Salva! How does it work? XS is quite beyond my abilities right now...

Replies are listed 'Best First'.
Re^3: Do the Schwartzian boogy!
by salva (Canon) on May 30, 2005 at 11:07 UTC
    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.