Last active
September 3, 2020 06:27
-
-
Save brainix/703b184743a005e4f6d16fa4ddf6b898 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def assertion_sort(list_): | |
try: | |
assert all(x <= y for x, y in zip(list_, list_[1:])) | |
except AssertionError: | |
random.shuffle(list_) | |
assertion_sort(list_) | |
if __name__ == '__main__': | |
assertion_sort(list_ := [2, 1, 4, 3, 5]) | |
print(list_) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment