Created
November 6, 2018 17:25
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like it's an "optimized" bubble sort, actually I think it might perform worse.