Created
March 14, 2017 11:59
-
-
Save kunthar/9d8962e1438e93f50dc6dd94d503af3d to your computer and use it in GitHub Desktop.
quicksort-with-lambda
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 qsort(get_list): | |
if len(get_list) < 2: | |
return get_list | |
pivot = get_list.pop() | |
left = list(filter(lambda x: x <= pivot, get_list)) | |
right = list(filter(lambda x: x > pivot, get_list)) | |
return qsort(left) + [pivot] + qsort(right) | |
sample_list=[1,65,7,8,32,45,67,90,100,201,12,56,73,2] | |
print(qsort(sample_list)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment