@a = (1,5,3);; @b = (5,2,1);; @sortedIndices = sort{ $b[ $a ] <=> $b[ $b ] } 0 .. $#b;; @a = @a[ @sortedIndices ];; @b = @b[ @sortedIndices ];; print "@a\n@b";; 3 5 1 1 2 5