bogo sort python code example
Example: bogo sort python
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 bogo_sort(data) -> list:
"""Shuffle data until sorted."""
count = 0
while not is_sorted(data):
shuffle(data)
temp_str = " "
count += 1
for i in range(len(data)):
temp_str = temp_str + " " + str(data[i])
print(temp_str)
print(count)
return data