Skip to content

Instantly share code, notes, and snippets.

@stevedya
Created July 12, 2019 17:50
Show Gist options
  • Save stevedya/60d550799f580aaac195e8ecc60a8f9c to your computer and use it in GitHub Desktop.
Save stevedya/60d550799f580aaac195e8ecc60a8f9c to your computer and use it in GitHub Desktop.
select sort example
def selectSort(nums):
for i in range(5):
minpos = i
for j in range(i, 6):
if nums[j] < nums[minpos]:
minpos = j
temp = nums[i] #hold old value
nums[i] = nums[minpos] #put new min value where old one was
nums[minpos] = temp #put old value where min used to be
print(nums)
nums = [5, 3, 8, 6, 7, 2]
selectSort(nums)
print (nums)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment