Skip to content

Instantly share code, notes, and snippets.

@kunthar
Created March 14, 2017 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunthar/9d8962e1438e93f50dc6dd94d503af3d to your computer and use it in GitHub Desktop.
Save kunthar/9d8962e1438e93f50dc6dd94d503af3d to your computer and use it in GitHub Desktop.
quicksort-with-lambda
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