//1.直接插入排序 //原理,依次遍历前n个子数组,第n个与前n-1个子数组比对,大小不对进行插入并移动 public int[] insertOrder(int[] num){ for (int i = 1; i < num.length; i++) { for (int j = 0; j < i; j++) { if(num[i]<num[j]){ int temp = num[i]; for (int k = 0; k < i-j; k++) { //进行移动 //System.out.println("temp="+temp+",i="+i+",j="+j); num[i-k] = num[i-1-k]; } num[j] = temp; } } } return num; }