1
const quickSort = function(arr) {
if (arr <= 1) return arr
const middleIndex = Math.floor(arr.length / 2)
const middle = arr.splice(middleIndex, 1)[0]
const left = []
const right = []
for(const item of arr) {
if (item < middle) {
left.push(item)
} else {
right.push(item)
}
}
return quickSort(left).concat([middle], quickSort(right))
}
console.log(quickSort([5,1,3,4,5,8,5,4,6,3,4,9,2]))
1