var arr = [38,49,65,97,76,13,27,49];
var BIN_INSERTSORT = function(arr){ var i, j,temp,low,mid,high; var n = arr.length; for( i = 1;i<=n-1;i++){ temp = arr[i]; low = 0; high = i-1; while(low<=high){ mid = Math.floor((low+high)/2); if(temp<arr[mid]){ high = mid-1; }else{ low = mid+1; } } for (j=i-1;j>=low;j--){ arr[j+1] = arr[j]; } arr[low] = temp; } }
BIN_INSERTSORT(arr);
console.log(arr);