计数排序
var countSort = function(array) { var i, z = 0, count = [], min = Math.min.apply({}, array), max = Math.max.apply({}, array), size = array.length; //给新数组预填为零 for (i = min; i <= max; i++) { count[i] = 0; } for (i=0; i < size; i++) { count[array[i]]++; } for (i = min; i <= max; i++) { while (count[i]-- > 0) {//循环新数组,如果不为零,则把i返回array array[z++] = i; } } return array; }
机器瞎学/数据掩埋/模式混淆/人工智障/深度遗忘/神经掉线/计算机幻觉/专注单身二十五年