Skip to content

Instantly share code, notes, and snippets.

@reterVision
Created January 11, 2014 14:05
Show Gist options
  • Save reterVision/9a10eabee5d288586096 to your computer and use it in GitHub Desktop.
Save reterVision/9a10eabee5d288586096 to your computer and use it in GitHub Desktop.
Bubble Sort
"""
Bubble Sort
"""
def bubble_sort(l):
i = 0
while i < len(l):
j = i + 1
while j < len(l):
if l[i] > l[j]:
l[i], l[j] = l[j], l[i]
j += 1
i += 1
return l
if __name__ == "__main__":
test_list = [7, 5, 6, 3, 2, 1, 9, 8, 10]
print bubble_sort(test_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment