- or download this
sub sortsub {
$a cmp $b ||
other_function( $a, $b ) ||
...
}
- or download this
sub sortsub {
string_compare( $a, $b ) ||
other_function( $a, $b ) ||
...
}
- or download this
sub sortsub {
my @subs = @_;
...
return $result if $result;
}
}
- or download this
sub make_sort_sub {
my @subs = @_;
...
}
};
}
- or download this
my $sort_sub = make_sort_sub( @sub_references );
my @sorted = sort { $sort_sub->() } @stuff;
- or download this
#!/usr/bin/perl
# pre-defined common sort subroutines
...
sort { $sort_sub->() } qw( Fred fred FReD Barney barney Betty BETT
+Y );
print "@sorted\n";
}