Created
July 12, 2019 17:50
-
-
Save stevedya/60d550799f580aaac195e8ecc60a8f9c to your computer and use it in GitHub Desktop.
select sort example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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