var ary=[1,2,3,5,47,86,9,24,77];
function quickSort(ary){
if(ary.length<=1){
return ary;
}
var cen=Math.floor(ary.length/2);
var cenVal=ary.splice(cen,1)[0];
var left=[];
var right=[];
for(var i=0;i<ary.length;i++){
var cur=ary[i];
if(cur<cenVal){
left.push(cur);
}else{
right.push(cur);
}
}
return quickSort(left).concat([cenVal],quickSort(right));
}
console.log(quickSort(ary));