public static void main(String [] arg){
int[] arr = {1,2,3,6,8,9,8,7,8,9,10,11};
for(int i = 1;i<arr.length;i++){
int result = arr[i];
int left = 0;
int right = i-1;
int middle = -1;
while(left <= right){
middle = left + (right - left) / 2;
if(arr[middle] > result){
right = middle - 1;
}else{
left = middle + 1;
}
}
for(int j = i-1;j>=left;j--){
arr[j + 1] = arr[j];
}
arr[left] = result;
}
for(int k = 0;k<arr.length;k++){
System.out.println(arr[k]);
}
}
06-13
2332
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)