SOURCE

var nums = [19, 97, 9, 17, 1, 8]
function quickSort(nums, left, right) {
    if (left >= right) {
        return nums;
    }

    var l = left;
    var r = right;
    var pivot = nums[l];

    while (l < r) {
        while (l < r && nums[r] >= pivot) {
            r--;
        }
        if (l < r) {
            nums[l] = nums[r];
        }
        while (l < r && nums[l] < pivot) {
            l++;
        }
        if (l < r) {
            nums[r] = nums[l];
        }
        if(l>=r){
            nums[l]=pivot;
        }
    }
    quickSort(nums,left,r-1);
    quickSort(nums,r+1,right);
}
quickSort(nums,0,nums.length-1)
console.log(nums);
console 命令行工具 X clear

                    
>
console