public static void sort(Comparable[] a) {
        int N = a.length;
        for (int k = N / 2; k >= 0; k--)
            sink(a, k, N);
        N = a.length - 1;
        while (N < a.length && N >= 0) {
            exch(a, 0, N);
            sink(a, 0, --N);
        }
    }