Skip to content

Instantly share code, notes, and snippets.

@en0
Created November 6, 2018 17:25
Show Gist options
  • Save en0/bd07ba2a82b88873a4790b79e94a7f7f to your computer and use it in GitHub Desktop.
Save en0/bd07ba2a82b88873a4790b79e94a7f7f to your computer and use it in GitHub Desktop.
Late night whiteboard session yielded this sort algorithm. I am unsure what the algorithm it is called.
def sort(s):
for i in range(len(s) - 1):
j = len(s) - 1
while j > i:
if s[i] > s[j]:
s[i], s[j] = s[j], s[i]
j -= 1
return s
@MrJerB
Copy link

MrJerB commented Nov 7, 2018

Looks like it's an "optimized" bubble sort, actually I think it might perform worse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment