My version of quicksort Algorithm as Wikipedia says do not sort nice : Yesterday I post the same question, a nice member called Prune helped my. But now, I do not know why it does not work.

    def partition(A,lo,hi):
    pivot = A[hi]
    i=lo
    #Swap
    for j in range(lo,hi-1):
        if (A[j] <= pivot):
            val=A[i]
            A[i]=A[j]
            A[j]=val
            i=i+1
        val=A[i]
        A[i]=A[hi]
        A[hi]=val
    return(i)

    def quicksort(A,lo,hi):
      if (lo<hi):
          p=partition(A,lo,hi)
          quicksort(A,lo,p-1)
          quicksort(A,p+1,hi)
          return(A)
If my input is [5,3,2,6,8,9,1] the output is [1, 2, 5, 3, 8, 9, 6], why is that?
