Skip to content

Instantly share code, notes, and snippets.

@robbie01
Last active December 31, 2016 04:43
Show Gist options
  • Save robbie01/317d289ffad19901f4d80b7e2ad1405e to your computer and use it in GitHub Desktop.
Save robbie01/317d289ffad19901f4d80b7e2ad1405e to your computer and use it in GitHub Desktop.
Selection sort implemented in Python 3
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