function quickSort(arr){
if(arr.length<=1){
return arr;
}
var lastIndex=arr.length-1;
var left=[], right=[];
for(var i=0;i<arr.length;i++){
if(arr[i]>arr[lastIndex]){
right.push(arr[i]);
}
if (arr[i]<arr[lastIndex]){
left.push(arr[i]);
}
}return quickSort(left).concat(arr[lastIndex], quickSort(right));
}
//
console.log(quickSort([1,3,5,2,4,6]));
时间复杂度:O(nlgn)