Skip to content

Instantly share code, notes, and snippets.

@ivankahl
Created May 7, 2017 10:42
Show Gist options
  • Save ivankahl/81bcdcffe84c13fcd5b95d05acc10e98 to your computer and use it in GitHub Desktop.
Save ivankahl/81bcdcffe84c13fcd5b95d05acc10e98 to your computer and use it in GitHub Desktop.
bubbleSort.py
def bubble_sort(arr):
i = len(arr)
sorted = False
while(not sorted):
sorted = True
for j in range(0, i - 1):
if arr[j + 1] < arr[j]:
arr[j + 1], arr[j] = arr[j], arr[j + 1]
sorted = False
i -= 1
return arr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment