function insertionSort(items) {
var len = items.length;
for (var i = 0; i < len; i++) {
var value = items[i];
for (var j = i-1; j > -1 && items[j] > value; j--) { //内层循环是什么意思?代码不明白
console.log(i,j,items[j]);
items[j+1] = items[j];
}
items[j+1] = value;
}
return items;
};
林逸舟丶
cnyballk
相关分类