Given an array of size `n`, the problem is to return first `k` smallest elements, in sorted order.
My idea was to update an QuickSort algorithm , to find first the first `k` element and then recursive update problem to find `k-1` biggest elements. 
Can't find where my mistake is.

```
    def partition(a, left, right):
      pivot = a[left]
      p = left
      q = right
      while(p < q):
        while(a[q] > pivot and p < q):
          q-=1
        while(a[p] <= pivot and p < q):
          p+=1
        a[p] , a[q] = a[q] , a[p]
      a[left],a[p]=a[p],a[left]
      return p

    def kthSmallest(a, left, right, k,c=0):
      if left>=right:
        return a[c:]
      else:
        curr = partition(a, left, right)
        if curr - left == k - 1:
          return kthSmallest(a, left,curr-left-1,k-1,c+1)
        if(curr - left > k - 1):
          return kthSmallest(a, left, curr-1, k,c)
        return kthSmallest(a, curr+1, right, k - (curr - left + 1),c)

temp=[8,5,2,1,6,7,4,9,0]

print(kthSmallest(a,0,len(temp)-1,2))

```