Skip to content

Instantly share code, notes, and snippets.

@globby
Created March 3, 2014 23:42
Show Gist options
  • Save globby/9337085 to your computer and use it in GitHub Desktop.
Save globby/9337085 to your computer and use it in GitHub Desktop.
The Selection Sort algorithm
def selection(a):
if len(a) < 2: return
for i in range(0,len(a)):
k = i
for j in range(i+1,len(a)):
if a[j] < a[k]: k = j
a[i], a[k] = a[k], a[i]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment