Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saadh393/a04259eaa484ceff49fc0b7776726c50 to your computer and use it in GitHub Desktop.
Save saadh393/a04259eaa484ceff49fc0b7776726c50 to your computer and use it in GitHub Desktop.
Python Algorithm Practice
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