Last active
December 31, 2016 04:43
-
-
Save robbie01/317d289ffad19901f4d80b7e2ad1405e to your computer and use it in GitHub Desktop.
Selection sort implemented in Python 3
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
def selectionsort(list): | |
n = [] | |
while len(list) > 1: | |
n.append(list.pop(list.index(min(list)))) | |
return n | |
if __name__ == '__main__': | |
from sys import argv | |
from random import shuffle | |
list = list(range(int(argv[1]))) | |
shuffle(list) | |
list = selectionsort(list) | |
print(all(list[i] <= list[i+1] for i in range(len(list)-1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment