partitions items into elements equal to items[pivot]
followed by elements greater than items[pivot].
it assumed that items[a..b] does not contain elements smaller than the items[pivot].
fn partitionEqual(a: usize, b: usize, pivot: usize, context: anytype) usize
fn partitionEqual(a: usize, b: usize, pivot: usize, context: anytype) usize {
// move pivot to the first place
context.swap(a, pivot);
var i = a + 1;
var j = b - 1;
while (true) {
while (i <= j and !context.lessThan(a, i)) i += 1;
while (i <= j and context.lessThan(a, j)) j -= 1;
if (i > j) break;
context.swap(i, j);
i += 1;
j -= 1;
}
return i;
}