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); } HyperLogLogPlus(int p);  HyperLogLogPlus(int p, int sp);  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); @Override boolean offerHashed(long hashedLong); @Override boolean offerHashed(int hashedInt); @Override boolean offer(Object o); @Override long cardinality(); @Override int sizeof(); @Override byte[] getBytes(); int[] sortEncodedSet(int[] encodedSet, int validIndex); void addAll(HyperLogLogPlus other); @Override IRichCardinality merge(IRichCardinality... estimators);  }
@Test public void testSortEncodedSet() { int[] testSet = new int[3]; testSet[0] = 655403; testSet[1] = 655416; testSet[2] = 655425; HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(14, 25); testSet = hyperLogLogPlus.sortEncodedSet(testSet, 3); assertEquals(655403, testSet[0]); assertEquals(655425, testSet[1]); assertEquals(655416, testSet[2]); }