Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created Nov 29, 2020
Embed
What would you like to do?
def bubble_sort(array):
n = len(array)
for i in range(n):
for j in range(0, n-i-1):
if array[j] > array[j+1]:
array[j], array[j+1] = array[j+1], array[j]
array = [64, 56, 78, 34, 98, 32, 67]
bubble_sort(array)
print("Sorted array using Bubble Sort Algorithm : ")
for i in range(len(array)):
print(array[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment