functionquick(arr) { var len=arr.length; if (len <= 1) { return arr; } else { var coordIndex = Math.floor(len / 2); var coord = arr[coordIndex]; arr.splice(coordIndex, 1); var left = []; var right = []; var len2 = arr.length; for (var i = 0; i < len2; i++) { if (arr[i] < coord) { left.push(arr[i]); } else { right.push(arr[i]); } } var leftArr=quick(left); var rightArr=quick(right); return leftArr.concat([coord],rightArr); } }