Skip to content

Instantly share code, notes, and snippets.

@Lazzlo2096
Last active January 4, 2019 10:47
Show Gist options
  • Save Lazzlo2096/f81c9560a7e066eae33d80b9da90b8a9 to your computer and use it in GitHub Desktop.
Save Lazzlo2096/f81c9560a7e066eae33d80b9da90b8a9 to your computer and use it in GitHub Desktop.
# https://ru.wikipedia.org/wiki/Bogosort
import random
#random.sample(a, b) # https://docs.python.org/3.7/library/random.html#random.sample
def isSorted(list):
for i in range(len(list)-1):
if not(list[i] < list[i+1]):
return False
return True
#list2 = [1,2,4,5]
#print(isSorted(list2)) # True
list = [1,100,64,13,55,8,66,44,22]
while not isSorted(list):
list = random.sample(list, len(list))
print(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment