Created
February 8, 2016 16:28
-
-
Save himkt/6e619075308ad2a86734 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
def quick_sort(arr): | |
lower_than_or_equal_head = [elem for elem in arr if elem < arr[0]] | |
greater_than_head = [elem for elem in arr if elem > arr[0]] | |
if len(arr) < 2: return arr | |
return quick_sort(lower_than_or_equal_head) + [arr[0]] + quick_sort(greater_than_head) | |
print(quick_sort([1, 3, 4, 2, 1000, 10, 4])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment