Created
November 5, 2019 16:29
-
-
Save bashkirtsevich/da4440ed2ca5610d021fa54aaa9fa386 to your computer and use it in GitHub Desktop.
Quicksort
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
from itertools import tee, chain | |
def sort_c(it): | |
xs = iter(it) | |
x = next(xs) | |
xs1, xs2 = tee(xs) | |
yield from chain( | |
sort_c(filter(lambda i: i < x, xs1)), | |
[x], | |
sort_c(filter(lambda i: i >= x, xs2)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment