in reply to sorting two arrays together

You can sort the indexes:
my @index = 0..$#a; @index = sort { $a[$a] <=> $a[$b] } @index; my @sorted_a = @a[@index]; my @sorted_b = @b[@index]; use List::MoreUtils qw/zip/; my @combined_sorted = zip @sorted_a, @sorted_b;

Replies are listed 'Best First'.
Re^2: sorting two arrays together
by youlose (Scribe) on Dec 23, 2010 at 09:11 UTC
    Good solution, but i'll try to reduce memory consumption of it:
    my @index = 0..$#a; @index = sort { $a[$a] <=> $a[$b] } @index; my @combined_sorted = map { $a[$_],$b[$_] } @index;