超容易记的快排,改写自Acwing的cpp代码 ```js function sort(arr) { quickSort(arr, 0, arr.length - 1); console.log(arr); } function quickSort(arr, left, right) { if (left >= right) return; let x = arr[Math.floor((left + right) / 2)]; let i = left - 1, j = right + 1; while (i < j) { for (i ++; arr[i] < x; i ++ ); for (j --; arr[j] > x; j -- ); if (i < j) { [arr[i], arr[j]] = [arr[j], arr[i]]; } } quickSort(arr, left, j); quickSort(arr, j + 1, right); } ```