SOURCE

// 快速排序
const sort = (list = []) => {
    if (list.length < 2) return list
    const middle = list.splice([~~(list.length / 2)], 1)[0]

    const left = []
    const right = []
    for (let i = 0, len = list.length; i < len; i++) {
        const cur = list[i]
        cur < middle ? left.push(cur) : right.push(cur)
    }

    return [...sort(left), middle, ...sort(right)]
}

const arr = [3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48]
console.log(sort(arr))
console 命令行工具 X clear

                    
>
console