in reply to Sorting multiple arrays
If array_b starts at zero and doesn't skip values, you can use an array similarly:my %h; @h{@array_b} = @array_a; # Now you can sort however you want, and they're linked: for (sort {$a <=> $b} keys %h) { print "$_: $h{$_}\n"; }
If it skips some values (but doesn't range into absurdly high numbers) and/or doesn't start at zero, you can grep out the undefs (assuming you don't have valid undef values):my @sorted_values; @sorted_values[@array_b] = @array_a; # magically sorted!
# same as above, then @sorted_values = grep defined, @sorted_values;
|
|---|