I am trying to implement the inplace quick sort as explained in the http://en.wikipedia.org/wiki/Quicksort
Below is the python code, The partition function does not work as expected.
def swap(array, index1, index2):
    tmp = array[index1]
    array[index1] = array[index2]
    array[index2] = tmp
def partition(array, left, right, pivotIndex):
    pivotValue = array[pivotIndex]
    swap(array, pivotIndex, right)
    storeIndex = left
    for i in range(left, right - 1):
        if array[i] < pivotValue:
            swap(array, i, storeIndex)
            storeIndex = storeIndex + 1
            print array, i
    swap(array, storeIndex, right)
    return storeIndex
def quicksort(array, left ,right):
    if right > left:
        print left, right
        pivotIndex = left
        pivotNewIndex = partition(array, left, right, pivotIndex)
        quicksort(array, left, pivotNewIndex - 1)
        quicksort(array, pivotNewIndex + 1, right)
if __name__ == '__main__':
    array = [3,7,8,5,2,1,9,5,4]
    partition(array, 0, len(array) - 1, 3) # 5 is pivot
    print array # expecting all the elements to the left of pivot value(5) will be lesser or equal.
 
     
    