Created
May 9, 2022 00:23
-
-
Save ruimaranhao/8009857b8975d5b5026991e5fcdb7a9e to your computer and use it in GitHub Desktop.
Crazy simple sorting
This file contains hidden or 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
# Described in As found in https://arxiv.org/pdf/2110.01111.pdf. | |
import random | |
def generate_random_list(size, min_value=0, max_value=10): | |
return random.sample(range(min_value, max_value), size) | |
def simple_sort(lst): | |
for i in range(len(lst)): | |
for j in range(len(lst)): | |
if lst[i] < lst[j]: | |
lst[i], lst[j] = lst[j], lst[i] | |
if __name__ == '__main__': | |
random_list = generate_random_list(20, 0, 30) | |
print("Original list: {}".format(random_list)) | |
simple_sort(random_list) | |
print("Sorted list: {}".format(random_list)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment