in reply to Choosing the sort routine on the fly

This works for me:
my $s = $sorter->[$offset]; print "$_\n" for sort $s @list;
It's a bit kludgey, but it works.

Also, I had to remove the prototypes from forward and backward to get them to work; according to sort's documentation, prototypes cause the parameters to be passed in @_ instead of $a and $b.

Replies are listed 'Best First'.
Re^2: Choosing the sort routine on the fly
by Skeeve (Parson) on Sep 08, 2006 at 23:26 UTC
    See my updated post above with 2 cites from perldoc -f sort. They explain why you had to remeove the prototype and had to add an aditional variable $s.

    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e