def quick_sort(lists,left,right):
    if left>=right:
        return lists
    key=lists[left]
    low=left
    high=right
    while left<right:
        while left<right and lists[right]>=key:
            right-=1
        lists[left]=lists[right]
        while left<right and lists[left]<=key:
            left+=1
        lists[right]=lists[left]
        print(lists)
    lists[left]=key
    quick_sort(lists,low,left-1)
    quick_sort(lists,left+1,high)
    return lists
list=[5,8,7,6,9,4,3,2,1]
list=quick_sort(list,0,len(list)-1)
print(list)
