Last Updated: February 25, 2016
·
873
· soasme

Quick Sort in Python

A quick implementation of qsort in python:

def qsort(a):
    if not a:
        return []
    first = a[0]
    lesser = filter(lambda i: i < first, a[1:])
    greater = filter(lambda i: i >= first, a[1:])
    return qsort(lesser) + [first] + qsort(greater)