photo.heic

Pivot Helper

Picking a pivot

let arr = [5, 2, 1, 8, 4, 7, 6, 3]

pivot(arr);

arr;
// any one of these is an acceptable mutation
// [2,1,4,3,5,8,7,6]
// [1,4,3,2,5,8,7,6]
// [3,2,1,4,5,8,7,6]
// [4,1,2,3,5,6,8,7]
// there are other acceptable mutations too!