//å¨ä¸æ®µæåºæ°ç»ä¸æå
¥ä¸ä¸ªæ°å
const array = [1,2,4,8,9]
const b = 3
const index = array.find(a=>a>b)
if(index===undefined){
array.push(b)
}else{
array.splice(index,0,b)
}
//ç®åç
const index1 = array.indexOf(b)
array.splice(index1===-1?array.length:index1,0,b)
//åå§å®ç°æ¹å¼
function inster(A,x){
//pæåä¸ä¸ä¸ªè¦æ¯è¾çå
ç´
//p+1æå空ä½
let p = A.length-1
while(p>=0&&A[p]>x){
A[p+1] = A[p]
p--
}
A[p+1]=x
}
//æ´ä¸ªæå
¥æåºçè¿ç¨
//1.æ°ç»ç第ä¸ä¸ªå
ç´ ååé¢ä¸ä¸ªå
ç´ æ¯è¾
function insertion_sort(A){
for(let i = 1;i