import java.util.Arrays;
public class T {
public static void binaryInsertSort(int[] data) {
int arrayLength = data.length;
for (int i = 1; i < arrayLength; i++) {
int tmp = data[i],low = 0,high = i - 1;
while (low <= high) {
int mid = (low + high) / 2;
if (tmp > data[mid]) {
low = mid + 1;
} else {
high = mid - 1;
}
}
for (int j = i; j > low; j--) {
data[j] = data[j - 1];
}
data[low] = tmp;
System.out.println(Arrays.toString(data));
}
}
public static void main(String[] args) {
int[] arr = {3, 6, 2, 5, 1, 90};
System.out.println("排序之前:" + Arrays.toString(arr));
binaryInsertSort(arr);
System.out.println("排序之后:" + Arrays.toString(arr));
}
}