Skip to content

Instantly share code, notes, and snippets.

@srakrn
Created December 8, 2017 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srakrn/377972bcbeabe9daaa0d5a0e62d19c1b to your computer and use it in GitHub Desktop.
Save srakrn/377972bcbeabe9daaa0d5a0e62d19c1b to your computer and use it in GitHub Desktop.
def bubble_sort(l):
for i in range(len(l)):
border = len(l)-i-1
for j in range(border):
if l[j] > l[j+1]:
l[j], l[j+1] = l[j+1], l[j]
return l
import random
l = [random.randint(1, 20) for _ in range(20)]
print(bubble_sort(l))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment