Skip to content

Instantly share code, notes, and snippets.

@m00nlight
Created February 3, 2015 11:26
Show Gist options
  • Save m00nlight/61839e7007f95d8c13b3 to your computer and use it in GitHub Desktop.
Save m00nlight/61839e7007f95d8c13b3 to your computer and use it in GitHub Desktop.
Functional style of quick sort in python
def quick_sort(nums):
if len(nums) <= 1:
return nums
else:
less = filter(lambda x: x <= nums[0], nums[1:])
large = filter(lambda x: x > nums[0], nums[1:])
return quick_sort(less) + [nums[0]] + quick_sort(large)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment