function quickSort(arr) {if (arr.length === 0) {return []}const basicValue = arr[Math.floor((arr.length - 1) / 2)] // 随意取, 这里取中间const left = []const right = []for (let i = 0; i < arr.length; i++) {if (arr[i] < basicValue) {left.push(arr[i])}if (arr[i] > basicValue) {right.push(arr[i])}}return quickSort(left).concat(basicValue, quickSort(right))}
先记住 O(NlogN), 具体证明, someday to understand, o(╯□╰)o