Open Betty985 opened 2 years ago
function quickSort(arr){ if(arr.length<=1) return arr let paritionIndex=Math.floor(arr.length/2) let tmp=arr[paritionIndex] let left=[] let right=[] for(let i=0;i<arr.length;i++){ if(i==paritionIndex) continue if(arr[i]<tmp){ left.push(arr[i]) }else{ right.push(arr[i]) } } return quickSort(left).concat([tmp],quickSort(right)) }
思想
代码