class HyperLogLogPlus implements IRichCardinality {

    public int[] sortEncodedSet(int[] encodedSet, int validIndex) {
        List<Integer> sortedList = new ArrayList<Integer>();
        for (int i = 0; i < validIndex; i++) {
            int k = encodedSet[i];
            sortedList.add(k);
        }

        Collections.sort(sortedList, new Comparator<Integer>() {
            @Override
            public int compare(Integer left, Integer right) {
                if (left.equals(right)) {
                    return 0;
                }
                int leftIndex = getSparseIndex(left);
                int rightIndex = getSparseIndex(right);
                if (leftIndex < rightIndex) {
                    return -1;
                } else if (rightIndex < leftIndex) {
                    return 1;
                }
                int leftHash = getEncodedHash(left);
                int rightHash = getEncodedHash(right);
                if (leftHash < rightHash) {
                    return -1;
                } else if (rightHash < leftHash) {
                    return 1;
                }
                return 0;
            }
        });
        return toIntArray(sortedList);
    }

    public  HyperLogLogPlus(int p);
    public  HyperLogLogPlus(int p, int sp);
    public  HyperLogLogPlus(int p, int sp, List<byte[]> deltaByteSet);
    private  HyperLogLogPlus(int p, int sp, int[] sparseSet);
    private  HyperLogLogPlus(int p, int sp, RegisterSet registerSet);
    private  HyperLogLogPlus(int p, int sp, int[] sparseSet, RegisterSet registerSet);

}