Test-IPython-on-blog 25 Apr 2016 Quick Sort In [2]: def quicksort(arr): if len(arr) <= 1: return arr pivot = arr[len(arr) / 2] left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] return quicksort(left) + middle + quicksort(right) def main(): unsort_arr = [3,6,8,10,1,2,1] print 'before', unsort_arr print 'after', quicksort(unsort_arr) if __name__ == '__main__': main() before [3, 6, 8, 10, 1, 2, 1] after [1, 1, 2, 3, 6, 8, 10] In [ ]: