插入排序

 1 public static void insertion_sort(int[] a){
 2         for(int i = 1; i < a.length; i++) {
 3             if(a[i-1] > a[i]) {
 4                 int temp = a[i];
 5                 int j = i;
 6                 while(j > 0 && a[j-1] > temp) {
 7                     a[j] = a[j-1];
 8                     j--;
 9                 }
10                 a[j] = temp;
11             }
12         }
13     }  
插入排序
原文地址:https://www.cnblogs.com/yixiu868/p/6552557.html