Skip to content

Instantly share code, notes, and snippets.

@ngenator
Created August 8, 2013 00:19
Show Gist options
  • Save ngenator/6180266 to your computer and use it in GitHub Desktop.
Save ngenator/6180266 to your computer and use it in GitHub Desktop.
def selection_sort(to_sort):
for i in range(len(to_sort) - 1):
minimum = i
for j in range(len(to_sort) - 1):
if to_sort[j] < to_sort[minimum]:
minimum = j
temp = to_sort[i]
to_sort[i] = to_sort[minimum]
to_sort[minimum] = temp
return to_sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment