原理
待更新
代码如下:
let insetSort = function (arr) {
let inner, temp;
for (let outer = 1, len = arr.length; outer < len; outer++) {
temp = arr[outer]
inner = outer
while (inner > 0 && arr[inner - 1] > temp) {
arr[inner] = arr[inner - 1]
inner--
}
arr[inner] = temp
}
return arr
}