in reply to Sorting multiple arrays

Try using a hash of arrays or hash of hashes. Without more info it's not clear which is better for your application. This way you can sort the hash by keys or by a particular value, or whatever. if array_a is names, array_b is birth_order and array_c is salary (just for example) you could replace those arrays with a structure like this:
# First make a hash to hold it all my %p = (); # p is short for people so I can type less. # bob, fred, peter and john are keys of %p, and refs to # hashes we didn't predeclare. This is what makes hashes # of hashes (or arrays) so useful, they are easily # populated from unknown data. $p{bob}{birth_order} = 1; $p{fred}{birth_order} = 2; $p{peter}{birth_order} = 3; $p{john}{birth_order} = 4; $p{bob}{salary} = 50000; $p{fred}{salary} = 60000; $p{peter}{salary} = 70000; $p{john}{salary} = 80000; # to sort by the people's names: for my $name ( sort keys %p ){ # do something here } # to sort by the people's birth order: for my $name ( sort { $p{$a}{birth_order} <=> $p{$b}{birth_order} } +keys %p ) { print "$p{$name}{birth_order}, $name\n"; }
I wrote out a bit of it long hand just to illustrate, but there are certainly better ways of creating these hashes.