'''
Online Python Compiler.
Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.
'''
def quickSort(a, l, r):
if l < r:
p = wrongPartition(a, l, r)
quickSort(a, l, p - 1)
quickSort(a, p + 1, r)
def partition(a, l, r):
pivot = a[l]
i = l + 1
j = r
while i <= j:
while i <= j and a[i] < pivot:
i += 1
while i <= j and a[j] >= pivot:
j -= 1
print (i, j)
break
if i < j:
a[i], a[j] = a[j], a[i]
a[l], a[j] = a[j], a[l]
print(a)
return j
def wrongPartition(a, l, r):
pivot = a[l]
i = l + 1
j = r
while i <= j:
while i < j and a[i] < pivot:
i += 1
while i <= j and a[j] >= pivot:
j -= 1
print (i, j)
break
if i < j:
a[i], a[j] = a[j], a[i]
return
a[l], a[j] = a[j], a[l]
print(a)
return j
a = [14,6,8,1,4,9,2,1,7,10,5]
quickSort(a, 0, len(a) - 1)
print(a)