桶排序 function sort(arr) { var newArr = new Array(arr.length); var newArr1 = []; for (let i = 0, l = arr.length; i l; i++) { newArr[i] = 0; } for (let i = 0, l = arr.length; i l; i++) { newArr[arr[i]] = newArr[arr[i]] + 1; } for (var i
function sort(arr) { var newArr = new Array(arr.length); var newArr1 = []; for (let i = 0, l = arr.length; i < l; i++) { newArr[i] = 0; } for (let i = 0, l = arr.length; i < l; i++) { newArr[arr[i]] = newArr[arr[i]] + 1; } for (var i = arr.length; i > 0; i--) { for (var j = 1; j <= newArr[i]; j++) newArr1.push(i); } return newArr1; }