package sort;
import java.util.Arrays;
public class SortPlus {
public static void main(String[] args) {
int a[] = {8, 9, 1, 7, 2, 3, 5, 4, 6, 0,};
SortPlus.sort(a);
System.out.println(Arrays.toString(a));
}
//实际就是分组后的插入
public static void sort(int[]a){
for(int gap=a.length/2;gap>0;gap/=2){
for (int i = gap; i <a.length ; i++) {
int index=i;//i为等待插入数字的小标
int value=a[i];//value为插入的数字
if(a[index]<a[index-gap]){
while(index-gap>=0&&value<a[index-gap]){
a[index]=a[index-gap];
index-=gap;
}
a[index]=value;
// System.out.println(Arrays.toString(a));
}
}
}
}