Skip to content

Instantly share code, notes, and snippets.

@saadh393
Created April 3, 2020 18:06
Show Gist options
  • Save saadh393/fa9cebc02333eed9fe0cf1ca273f244e to your computer and use it in GitHub Desktop.
Save saadh393/fa9cebc02333eed9fe0cf1ca273f244e to your computer and use it in GitHub Desktop.
def bublesort(list):
n = len(list)
# [3,1,9,5,7,2]
for i in range (0,n-1):
for j in range (0, n-i-1):
if list[j] > list[j+1]:
list[j], list[j+1] = list[j+1], list[j]
if __name__ == "__main__":
list = [3,1,9,5,7,2]
bublesort(list)
print(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment