Skip to content

Instantly share code, notes, and snippets.

@lohxx
Created February 26, 2018 22:03
Show Gist options
  • Save lohxx/235ef82cc39a920b01a81ab05ae9921f to your computer and use it in GitHub Desktop.
Save lohxx/235ef82cc39a920b01a81ab05ae9921f to your computer and use it in GitHub Desktop.
def swap(min,max,arr):
arr[max],arr[min] = arr[min],arr[max]
return arr[max]
def bubble_sort(arr):
for i in range(len(arr)):
for j in range(len(arr)-1):
if arr[j] > arr[j+1]:
swap(j,j+1,arr)
print(arr)
bubble_sort([x for x in range(15,-1,-1)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment