1.快速排序 var arr = [1, 2, 5, 6, 3, 1, 4]; function mySort(arr) { if (arr.length <= 1) { return arr; } // 获取中间值的索引 var len = Math.floor(arr.length / 2); // 截取中间值 var middle = arr.splice(len, 1); var left = []; var right = []; for (var i = 0; i < arr.le…
非原创: var quickSort = function(arr){ if(arr.length<=1){return arr;} var pivotIndex = Math.floor(arr.length/2); var pivot = arr.splice(pivotIndex,1)[0]; var left = []; var right = []; for(var i=0;i<arr.length;i++){ if(arr[i]<pivot){ left.push(arr[i…