const _quickSort = array => {
if(!array||!array.length){
return array
}
let first=array[0];
let left=[];
let right=[];
for(let i=1;i<array.length;i++){
if(array[i]<first){
left.push(array[i])
}else{
right.push(array[i])
}
}
left =_quickSort(left);
right=_quickSort(right);
left.push(first)
return left.concat(right)
}
console.log(_quickSort([0,-1,1,-2,2]))
结果: