Quick sort implementation ideas
- Figure out half the length of the array, take out the intermediate value, and the index value of the intermediate value
- Walk through the array, putting the item that is greater than the middle value in one array, and the item that is less than the middle value in the other array
- Recurse again for the larger and smaller arrays
Concrete code implementation
If (arr. Length <= 1) {return arr} var index = math.floor (arr. Length / 2) // Var midValue = arr.splice(index, 1)[0] let left = [], If (item < midValue) {left.push(item)} else {if (item < midValue) {left.push(item)} else { right.push(item) } }) return quickSort(left).concat([midValue], QuickSort (right)) // Recursively loop left and right again until arr.length <= 1, jump out, calculate the result}