in reply to sorting of two perl arrays

When dealing with parallel arrays, the bond between them is the indexes. That means you need to sort the indexes.
my @eles = ( 1, 5, 3 ); my @prios = ( 5, 2, 1 ); my @idxes = sort { $prios[$a] <=> $prios[$b] } 0..$#eles; @eles = @eles [ @idxes ]; @prios = @prios[ @idxes ]; print(join(', ', @eles), "\n");