in reply to Choosing the sort routine on the fly
Simply supply the sort routine's name.#! /usr/local/bin/perl -w use strict; sub forward {$a cmp $b} # removed prototype sub backward {$b cmp $a} # removed prototype my @sorter = qw/forward backward/; my @list = qw(kholsky stencil dnubietna barkhausen manganese fairing fleische flake schlozhauer gascoigne); my $offset = shift || 0; my $subname= $sorter[$offset]; print "$_\n" for sort $subname @list;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Choosing the sort routine on the fly
by kwaping (Priest) on Sep 08, 2006 at 15:42 UTC |