QuantumBogoSort a quantum sorting algorithm which can sort any list in O(1), using the "many worlds" interpretation of quantum mechanics.
It works as follows:
1. Quantumly randomise the list, such that there is no way of knowing what order the list is in until it is observed. This will divide the universe into O(n!) universes; however, the division has no cost, as it happens constantly anyway.
2. If the list is not sorted, destroy the universe. (This operation is left as an exercise to the reader.)
3. All remaining universes contain lists which are sorted.
As described above, is not a StableSort. A stable version might be produced as follows:
1. Configure the quantum randomiser to produce random code, rather than shuffle lists. Instruct it to generate some code.
2. If the resulting code is not a stable QuantumBogoSort, destroy the universe.
3. All remaining universes now have a stable QuantumBogoSort algorithm.