Skip to content

Instantly share code, notes, and snippets.

@ls0f
Created September 11, 2015 15:35
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 ls0f/e4aad8f471eef23ab5d3 to your computer and use it in GitHub Desktop.
Save ls0f/e4aad8f471eef23ab5d3 to your computer and use it in GitHub Desktop.
#coding:utf-8
def quick_sort(sort_list):
if len(sort_list) <= 1:
return sort_list
m = sort_list[0]
return quick_sort(filter(lambda x: x<=m, sort_list[1:])) + [m] + \
quick_sort(filter(lambda x: x>m, sort_list[1:]))
if __name__ == "__main__":
print quick_sort([1])
print quick_sort([3,1])
print quick_sort([3,1,9,0,4,9,0,4,1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment