Created
February 3, 2015 11:26
-
-
Save m00nlight/61839e7007f95d8c13b3 to your computer and use it in GitHub Desktop.
Functional style of quick sort in python
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 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