#6: Bogosort

Tagged as challenge

Written on 2018-01-30

Implement Bogosort. Bogosort is a sorting algorithm defined as so:

INPUT x: a finite sequence of numbers
OUTPUT: the input sequence in ascending order

Step 1. If x is in ascending order, return x.
Step 2. Shuffle the elements of x uniformly randomly. Go to Step 1.

Unless otherwise credited all material copyright © 2010–2018 by Robert Smith