Skip to content

Instantly share code, notes, and snippets.

@arshinalbab
Created November 29, 2020 04:44
Show Gist options
  • Select an option

  • Save arshinalbab/80120a3e20d34bcf04f419079b8714fe to your computer and use it in GitHub Desktop.

Select an option

Save arshinalbab/80120a3e20d34bcf04f419079b8714fe to your computer and use it in GitHub Desktop.
BogoSort Implemented in python
from random import shuffle
def is_sorted(data) -> bool:
"""Determine whether the data is sorted."""
return all(data[i] <= data[i + 1] for i in range(len(data) - 1))
def bogosort(data) -> list:
"""Shuffle data until sorted."""
while not is_sorted(data):
shuffle(data)
return data
print(bogosort(["b", "a", "n"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment