There are many sorting methods. This section introduces the use of the push method of array to complete quick sorting.
function quickSort(arr){ if(arr.length <= 1) return arr;//Judge whether the array is valid var cut = Math.floor(arr.length/2);//Selse the middle subscript var left = [],right = []; var num = arr.splice(cut,1)[0];//Self the reference value for(var i = 0;i < arr.length;i ++){ if(arr[i] < num){ left.push(arr[i]);//Selse { right.push(arr[i]);//Self the big one on the right} } return quickSort(left).concat(num,quickSort(right));//Recursive}