Created
December 4, 2013 10:38
-
-
Save shoya140/7785552 to your computer and use it in GitHub Desktop.
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 quicksort(list): | |
if len(list) <= 1: | |
return list | |
pivot = list[0] | |
left = [] | |
right = [] | |
for val in list[1:len(list)]: | |
if val < pivot: | |
left.append(val) | |
else: | |
right.append(val) | |
left = quicksort(left) | |
right = quicksort(right) | |
return left + [pivot] + right | |
if __name__ == "__main__": | |
list = [3, 4, 7, 1, 8, 2, 9, 5] | |
print quicksort(list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
確かに内部ソートとは言えない気がしますね..
僕のクイックソートの書き方は関数型言語の定番なみたいなやつで,
ネットで定番の炎上案件みたいになってますね
http://togetter.com/li/445854