def swap(a, p, q): # print(\'p is: \', p) tmp = a[p] a[p] = a[q] a[q] = tmp return a def partition(a, q): # if flag == 0: # q is the PO