function quickSort(arr) {
if(arr.length == 1) {
return arr
}
let temp = arr.shift()
let left = [], right = []
arr.forEach(item => {
if(temp > item) {
left.push(item)
} else {
right.push(item)
}
})
return quickSort(left).concat([temp], quickSort(right))
}
console.log(quickSort([8,3,4,2,10,5,3]))
function sort(arr) {
for(let i = arr.length; i > 0; i--) {
for (let j = 0; j < i; j++)
if (arr[j] > arr[j+1]) {
let temp = arr[j]
arr[j] = arr[j+1]
arr[j+1] = temp
}
}
return arr
}
console.log(sort([8,3,4,2,10,5,3]))