my $adata = q(athings1 athings2); my $bdata = q(bthings1 bthings2); my $column = 0; # ... sort_func($column,$adata,$bdata); sub sort_func { my ($sortby,$astring,$bstring) = @_; # this function uses three arguments. } #### if ($sortby eq "string"){ my $result = sort { $b cmp $a } ($a_items[$item_no], $b_items[$item_no]); } # $result will contain the greater of the two values. #### my @a_items = split("\t", $astring,$limit); #store the remainder my $a_remainder = pop @a_items; my @b_items = split("\t", $bstring,$limit); #discard the remainder pop @b_items;