Created
May 7, 2017 10:42
-
-
Save ivankahl/81bcdcffe84c13fcd5b95d05acc10e98 to your computer and use it in GitHub Desktop.
bubbleSort.py
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 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