I'm using sort
with a customized comparison subroutine I've written:
sub special_compare {
# calc something using $a and $b
# return value
}
my @sorted = sort special_compare @list;
I know it's best use $a
and $b
which are automatically set, but sometimes I'd like my special_compare
to get more arguments, i.e.:
sub special_compare {
my ($a, $b, @more) = @_; # or maybe 'my @more = @_;' ?
# calc something using $a, $b and @more
# return value
}
How can I do that?