Bogosort "Stupid Sort"

Where randomness meets futility. Shuffle until sorted—hope is not a strategy.

Definition

Bogosort is the sorting algorithm that refuses to take life seriously. The idea is simple:

  1. Check if the array is sorted.
  2. If not, shuffle it at random.
  3. Repeat until sorted.

That is literally it—no guarantees, no efficiency, just chaos.

Complexity

On expectation Bogosort runs in O(n! · n) time because there are n! possible permutations and each shuffle costs O(n). In the worst case the algorithm might never terminate.

In the Gallery

See games/js/demos.js for an intentionally terrible implementation.

← Back to gallery