SOURCE

const partition = (list = [], left = 0, right = 0) => {
    const temp = list[left];

    while (left < right) {
        while (left < right && li[right] >= temp) {
            right--;
        }
        li[left] = li[right];

        while (left < right && li[left] <= temp) {
            left++;
        }
        li[right] = li[left];
    }

    li[left] = temp;

    return left;
}



const quick_sort = (list = [], left = 0, right = 0) => {
    if (left < right) {
        const mid = partition(list, left, right);
        quick_sort(list, left, mid - 1);
        quick_sort(list, mid + 1, right);
    }
}



console 命令行工具 X clear

                    
>
console