functionquickSort(list) { if (list.length <= 1) { return list; } let left = []; let right = []; for (let i = 1; i < list.length; ++i) { if (list[i] <= list[0]) { left.push(list[i]); } else { right.push(list[i]); } } returnquickSort(left).concat(list[0], quickSort(right)); } // 也可以用ES6数组的filter方法缩写上述代码 functionquickSort(list) { if (list.length <= 1) { return list; } let left = list.filter((x, i) => x <= list[0] && i != 0); let right = list.filter((x) => x > list[0]); returnquickSort(left).concat(list[0], quickSort(right)); }