var a=[1,3,2,5,4,7,6];
for(let i=1;i<a.length;i++){
let b=a[i],
index=i-1;
while(b<a[index]&&index>=0){
a[index+1]=a[index];
index--;
}
a[index+1]=b;
}
console.log(a);
var a=[1,3,2,5,4,7,6];
for(let i=1;i<a.length;i++){
let b=a[i],
index=i-1;
while(b<a[index]&&index>=0){
a[index+1]=a[index];
index--;
}
a[index+1]=b;
}
console.log(a);