in reply to sorting two arrays together
It can be done in one step, using an index. This leaves the original untouched, in the manner the OP requested:
use strict; my @a = qw (92 6 2); my @b = qw (60 5 12); my $i=0; my @c = map { $_->[0], $_->[1] } sort { $a->[0] <=> $b->[0] } map { [ $a[$i], $b[$i++] ] } @a; print join ' ', @c , "\n"; ## Prints 2 12 6 5 92 60
Cheers!
--marmot
In Section
Seekers of Perl Wisdom