That’s not the correct extrapolation from the many world interpretation of quantum mechanics (which is only one of many interpretations).
It is only that every possible behavior of quanta exist.
So in order to make the above code work, the initial order of the array needs to be determined by a quantum process. If it’s a macro process that doesn’t rely on quantum mechanics, then the above code would likely end up destroying all universes instead.