快速排序
var arr = [90,9,12,6,30,60,36,32,40]; function quickSort(arr){ if(arr.length<=1){ return arr } var l=Math.floor(arr.length/2) var lo =arr.splice(l,1)[0] var left=[] var right=[] for (var i=0;i<arr.length;i++){ if(arr[i]<=lo){left.push(arr[i])} else{ right.push(arr[i]) } } return quickSort(left).concat([lo],quickSort(right)) } console.log(quickSort(arr))