function quickSort(arr) { if (arr.length < 1) return arr; let mindIndex = Math.floor(arr.length / 2) let valArr = arr.splice(mindIndex, 1) let mindValue = valArr[0] let leftArr = [], rightArr = []; for (let i = 0; i < arr.length; i++) { if (arr[i] < mindValue) { leftArr.push(arr[i]) } else { rightArr.push(arr[i]) } } return quickSort(leftArr).concat(mindValue, quickSort(rightArr)) }