my @cols = ( [qw/ 1 2 3 4 5 1 6 7 8 9 1 /], [qw/ u b c d e a f g h i z /], ); my @idx = sort { $cols[0][$a] <=> $cols[0][$b] } 0 .. $#{ $cols[0] }; @$_ = @$_[@idx] for @cols;