Created
January 30, 2019 15:00
-
-
Save adriaanbd/6b8c45fbdfcfc08272b8a297d88491d9 to your computer and use it in GitHub Desktop.
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): | |
for i, val in enumerate(arr, len(arr): | |
for j, pal in enumerate(arr, len(arr[:-1]): | |
neighbor = arr[j + 1] | |
if pal > neighbor: | |
arr[j+1] = arr[j] # swap | |
arr[j] = neighbor # swap | |
return arr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment