Bogosort

Bogosort is an esoteric sorting algorithm that runs in $$O(n \times n!)$$. it is unstable, and not adaptive.

= Explanation = to bogosort an array, shuffle it. if it is not sorted after the shuffle, shuffle it until it is sorted.

= Example = take the array {2 5 1 6 2 3}.

Shuffle it.

{6 4 1 2 3 5}

Shuffle it.

{1 2 6 3 5 4}

approx. 12 mins later

{1 2 3 4 5 6}

Sorted!

= Pseudocode = procedure bogosort(array arr) do while not isSorted(arr) do shuffle(arr) end while end