Skip to content

Instantly share code, notes, and snippets.

@adriaanbd
Created January 30, 2019 15:00
Show Gist options
  • Save adriaanbd/6b8c45fbdfcfc08272b8a297d88491d9 to your computer and use it in GitHub Desktop.
Save adriaanbd/6b8c45fbdfcfc08272b8a297d88491d9 to your computer and use it in GitHub Desktop.
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