Skip to content

Instantly share code, notes, and snippets.

@devansh42
Last active December 29, 2020 15:04
Show Gist options
  • Save devansh42/bb690995e36d7c9b3cbd46c8a24713e6 to your computer and use it in GitHub Desktop.
Save devansh42/bb690995e36d7c9b3cbd46c8a24713e6 to your computer and use it in GitHub Desktop.
Imperative algorithm of bubble sort in python
def imperative_bubble_sort(ar):
for i in range(len(ar)):
for j in range(len(ar)-1-i):
if ar[j]>ar[j+1]:
ar[j],ar[j+1] = ar[j+1],ar[j]
return ar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment