rdmclin2
2/26/2016 - 2:24 PM

InsertSort

InsertSort

public static void sort(Comparable []a){
    for(int i = 1 ; i < a.length; i ++) {
        Comparable temp = a[i];
        int j = i;
        for(;j>0 && less(temp,a[j-1]);j--) {
            a[j] = a[j - 1];
        }
        a[j] = temp;
    }
}