Skip to content

Instantly share code, notes, and snippets.

@himkt
Created February 8, 2016 16:28
Show Gist options
  • Save himkt/6e619075308ad2a86734 to your computer and use it in GitHub Desktop.
Save himkt/6e619075308ad2a86734 to your computer and use it in GitHub Desktop.
# -*- 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