public static List extract(final Comparable[] array, final int k) {
        final int n = array.length - 1;
        // build heap; start from top
        for (int i = n / 2; i >= 0; i--) {
            heapify(array, n, i);
        }
        final List results = new ArrayList(k);
        for (int i = n; i > 0; i--) {
            results.add(array[0]);
            if (results.size() == k) {
                break;
            }
            swap(array, 0, i);
            heapify(array, n, 0);

        }
        return results;
    }