Created
September 11, 2019 07:54
-
-
Save shrkw/4759520d1d81c73134801e6fc37a345d 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 quick_sort(src): | |
print(f"**: {src}") | |
if len(src) <= 1: | |
return src | |
pivot = src[0] | |
left = list() | |
right = list() | |
for n in src[1:]: | |
if n < pivot: | |
left.append(n) | |
else: | |
right.append(n) | |
return quick_sort(left) + [pivot] + quick_sort(right) | |
def sort(src): | |
return quick_sort(src) | |
if __name__ == "__main__": | |
import random | |
src = random.sample(range(3000), k=100) | |
print(f"init: {src}") | |
result = sort(src) | |
print(f"result: {result}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment