// 插入排序 const insertSort = function(arr) { const list = arr.slice() for (let i = 0, len = list.length; i < len; i++) { for (let j = len - 1; j > i; j--) { if (list[j] <= list[i]) { [list[i], list[j]] = [list[j], list[i]] } } } return list } const arr = [6,3,9,2,7,5,1] console.log(insertSort(arr))