'''
QuickSort implementation
'''


def quick_sort(arr, l, r):
    i, j = l, r
    x = arr[(l + r) / 2]

    if len(arr) == 0:
        return arr

    while True:
        while arr[i] < x:
            i += 1
        while arr[j] > x:
            j -= 1
        if i <= j:
            arr[i], arr[j] = arr[j], arr[i]
            i += 1
            j -= 1

        if i >= j:
            break

        if l < j:
            quick_sort(arr, l, j)
        if i < r:
            quick_sort(arr, i, r)


if __name__ == '__main__':
    arr = [12, 4, 5, 6, 7, 3, 1, 15]
    quick_sort(arr, 0, len(arr) - 1)
    print arr

@@ -491,16 +491,556 @@
 i, r)%0A%0A%0A
+def partition(array, begin, end):%0A    pivot = begin%0A    for i in xrange(begin + 1, end + 1):%0A        if array%5Bi%5D %3C= array%5Bbegin%5D:%0A            pivot += 1%0A            array%5Bi%5D, array%5Bpivot%5D = array%5Bpivot%5D, array%5Bi%5D%0A%0A    array%5Bpivot%5D, array%5Bbegin%5D = array%5Bbegin%5D, array%5Bpivot%5D%0A    return pivot%0A%0A%0Adef quicksort(array, begin=0, end=None):%0A    if end is None:%0A        end = len(array) - 1%0A%0A    if begin %3E= end:%0A        return%0A%0A    pivot = partition(array, begin, end)%0A    quicksort(array, begin, pivot - 1)%0A    quicksort(array, pivot + 1, end)%0A%0A%0A
 if __nam
@@ -1077,24 +1077,24 @@
 12, 
-4
+2, 8
 , 5, 
-6, 7, 3, 1
+1, 6, 4
 , 15
@@ -1096,33 +1096,32 @@
 4, 15%5D%0A    quick
-_
 sort(arr, 0, len

add new & correct func