插入排序

插入排序

 1 public class InsertionSort extends Sort {
 2 
 3     public Comparable[] insertionSort(Comparable[] a) {
 4         int N = a.length;
 5         for (int i = 1; i < N; i++) {
 6             for (int j = i; j > 0 && less(a[j], a[j - 1]); j--) {
 7                 exch(a, j, j - 1);
 8             }
 9         }
10         return a;
11     }
12 
13 }
原文地址:https://www.cnblogs.com/mada0/p/4684402.html