Write the shortest function to implement bogosort. In specific, your function should:
- Take an array (or your language's equivalent) as input
- Check if its elements are in sorted order; if so, return the array
- If not, shuffle the elements, and start again
The shortest entry wins. In the case of a tie, a function that supports a custom comparator (and/or pseudorandom number generator) is favoured. Any remaining ties are resolved by favouring the earlier submission.
Clarifications: You can use any element type you want, as long as there's some way to order them, of course. Also, the shuffling has to be uniform; none of this "I'll just quicksort it and call it shuffled" business. :-)