function partition(arr, start, end){
const pivotValue = arr[end];
let pivotIndex = start;
for (let i = start; i < end; i++) {
if (arr[i] < pivotValue) {
[arr[i], arr[pivotIndex]] = [arr[pivotIndex], arr[i]];
pivotIndex++;
}
}
[arr[pivotIndex], arr[end]] = [arr[end], arr[pivotIndex]]
return pivotIndex;
};
function quickSortRecursive(arr, start, end) {
if (start >= end) {
return;
}
let index = partition(arr, start, end);
quickSortRecursive(arr, start, index - 1);
quickSortRecursive(arr, index + 1, end);
}
var arr = [99, 32, 323, 1, -89, 33, 21, 5, 992, -932, 22, 100]
quickSortRecursive(arr, 0, arr.length - 1)
console.log('arr', arr)