#!/usr/bin/env dpython A = [9,8,7,6,1,4,3,2,5] i = -1 # Left index j = len(A)-1 # Right index v = A[-1] # Pivot detect 'Partition done': detect 'Move element j down': i = i+1 if i==j: 'Partition done' if A[i] > v: A[j] = A[i] 'Move element j down' detect 'Move element i up': j = j-1 if j==i: 'Partition done' if A[j] < v: A[i] = A[j] 'Move element i up' A[j] = v print A