in reply to Re^2: Do the Schwartzian boogy!
in thread Do the Schwartzian boogy!
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).sub keysort (&@) { my ($keygen, @values) = @_; my @keys = map { &$keygen() } @values; my @ix = sort { $keys[$a] cmp $keys[$b] } 0..$#keys; @values[@ix]; }
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.
|
|---|