Demo entry 6346648

Bogo Sort

   

Submitted by anonymous on Feb 10, 2017 at 20:34
Language: Python 3. Code size: 257 Bytes.

from random import shuffle

def isSorted(data):
    for i in range(len(data) - 1):
        if data[i] > data[i + 1]:
            return False
    return True

def bogoSort(data):
    while not isSorted(data):
        shuffle(data)
    return data

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).