Skip to content

Instantly share code, notes, and snippets.

@rishi93
Last active November 3, 2015 07:01
Show Gist options
  • Save rishi93/ca04ca9dcecb2fdb8850 to your computer and use it in GitHub Desktop.
Save rishi93/ca04ca9dcecb2fdb8850 to your computer and use it in GitHub Desktop.
Selection Sort
def selectionsort(arr):
for i in range(0,len(arr)):
min_index = i
for j in range(i+1,len(arr)):
if arr[j] < arr[min_index]:
min_index = j
arr[min_index],arr[i] = arr[i],arr[min_index]
print(arr)
arr = [4,3,1,6,2,5]
selectionsort(arr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment