function swapNumber(arr,i,j){
    var temp = arr[i];
    arr[i]=arr[j];
    arr[j]=temp;
}

function mergeNumber(arr,low,high){
    const pivot = arr[high];
    let i = low-1;
    
    for(let j=low;j<=high-1;j++){
        if(arr[j]<=pivot){
            i++;
            swapNumber(arr,i,j);
        }
    }
   swapNumber(arr,i+1,high);
    return i+1;
}

function quickSort(arr,low,high){
    if(low<high){
        // Partition the array into two halves
        const pivot = mergeNumber(arr,low,high);
        // Recursively sort the left and right halves
        quickSort(arr,low,pivot-1);
        quickSort(arr,pivot+1,high);
    }
}

var arry = [2,9,15,19,22,90,4];
var n = arry.length;

console.log('Before Quick Sorting')
for(let i=0;i<=n;i++){
    console.log(arry[i]);
}

quickSort(arry,0,n-1);
console.log('After Quick Sorting');
for(let i=0;i<=n;i++){
    console.log(arry[i]);
}





Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: