Created
April 3, 2020 15:36
-
-
Save saadh393/a04259eaa484ceff49fc0b7776726c50 to your computer and use it in GitHub Desktop.
Python Algorithm Practice
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 sortedlist(list): | |
n = len(list) | |
for i in range (0, n-1): | |
index = i | |
for j in range (i+1, n): | |
if list[j] < list[index]: | |
index = j | |
if index != i: | |
list[i], list[index] = list[index], list[i] | |
if __name__ == "__main__": | |
x = [4, 6,1, 2, 7, 1] | |
sortedlist(x) | |
print((x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment