int[] num = new int[]{73,58,85,36,69,88,54,53,92,3};
for(int i=1;i<10;i++){
int j = i;
int thisNum = num[i];
while(j>0 && num[j-1] > thisNum){
num[j] = num[j-1];
--j;
}
num[j] = thisNum;
}
插入排序的思想是设置一个标志位,标志位左边为有序排列,包括被标记位及右边为无序排列,每次从无序排列拿出一位与有序排列对比插入位置即可,比冒泡排序速度快一倍左右,因为他的比较次数为N*(N-1)/4,略快于选择排序。