const arr = [1,5,7,4,5,8,4,2,1,4,4,0]
let l = 0;
r = arr.length - 1;
function swap(arr,i,j){
const temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
function quickSort(arr,l,r){
if(l>=r) return;
const m = partition(arr,l,r);
quickSort(arr,l,m-1);
quickSort(arr,m+1,r);
}
function partition(arr,l,r){
const refValue = arr[l];
let j = l;
for(let i = l+1; i <= r; i++){
if(arr[i] > refValue){
continue
}
if(arr[i] < refValue){
j += 1;
swap(arr,j,i);
}
}
swap(arr,l,j);
return j;
}
quickSort(arr,l,r)
console.log(arr)
console