SOURCE

function quicksort(arr){
    var temp = Number(arr[0]),
        leftArr = [],
        rightArr = [];
    for(var i = 1, len = arr.length;i < len;i++){
        if(Number(arr[i]) - temp < 0) leftArr.push(arr[i])
        else rightArr.push(arr[i])
    }
    if(arr.length <= 1) return arr
    return [].concat(quicksort(leftArr), temp, quicksort(rightArr))
}

var arr = quicksort([9, 5, 7, 2,6, 10, 4])

console.log(arr)
console 命令行工具 X clear

                    
>
console