my @indicies = sort { $list[$a] cmp $list[$b] } 0..$#list; my @rearranged = @list2[@indicies];