public class InserSort {
public static void main(String args[]){
int[] arr ={1,-5,84,95,101,55,44,81};
insert(arr);
System.out.println(Arrays.toString(arr));
}
public static void insert(int[] arry){
int num=0;
int index=0;
for(int i=1;i<arry.length;i++){
num=arry[i];
index=i-1;
while (index>=0&&num<arry[index]){
arry[index+1]=arry[index];
index--;
}
if(index+1!=i){
arry[index+1]=num;
}
}
}
}
共勉!