def bogosort(collection):
 def isSorted(collection):
  if (len(collection) < 2):
   return True
  for i in range((len(collection) - 1)):
   if (collection[i] > collection[(i + 1)]):
    return False
  return True
 while (not isSorted(collection)):
  random.shuffle(collection)
 return collection

def bogosort ( collection ) : def isSorted ( collection ) : if ( len ( collection ) < 2 ) : return True for i in range ( ( len ( collection ) - 1 ) ) : if ( collection [ i ] > collection [ ( i + 1 ) ] ) : return False return True while ( not isSorted ( collection ) ) : random . shuffle ( collection ) return collection
pure implementation of the bogosort algorithm in python .