Skip to content

Instantly share code, notes, and snippets.

@pknowledge
Created January 8, 2020 21:22
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 pknowledge/471d81b8a2454317a0e488f879fed2c1 to your computer and use it in GitHub Desktop.
Save pknowledge/471d81b8a2454317a0e488f879fed2c1 to your computer and use it in GitHub Desktop.
Python BubbleSort Sorting Algorithm | Python Data Structures and Algorithms
a=[2,23,14,7,32,39]
def bubbleSort(arr):
n=len(arr)
for i in range(n):
for j in range(n-1-i):
if arr[j]>arr[j+1]:
arr[j],arr[j+1]=arr[j+1],arr[j]
print(arr)
#print("The unosrted list is:")
#print(a)
bubbleSort(a)
#print("The sorted list is:")
#print(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment