private Integer[] getSortedCyclicShift(final byte[] data, final int size) {
        assert (data != null && size > 0);

        // Test wether there is always the same number
        boolean isSame = true;
        for (byte b : data) {
            if (b != data[0]) {
                isSame = false;
                break;
            }
        }
        if (isSame) {
            // Return an array with 0..(size-1)
            Integer[] indexes = new Integer[size];
            for (int i = 0; i < size; i++) {
                indexes[i] = i;
            }
            return indexes;
        }

        // Cyclic shifted strings comparator
        final Comparator<Integer> suffixCmp = new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                int i1 = o1.intValue();
                int i2 = o2.intValue();
                // Compare at most size bytes, in a cyclic way
                for (int j = 0; j < size; j++) {
                    // Unsigned byte sorting
                    final int d1 = ((int) data[i1]) & 0xff;
                    final int d2 = ((int) data[i2]) & 0xff;
                    final int c = Integer.compare(d1, d2);
                    if (c != 0) {
                        return c;
                    }
                    i1 = (i1 + 1) % size;
                    i2 = (i2 + 1) % size;
                }
                // By default, compare integers
                return Integer.compare(i1, i2);
            }
        };

        // Build a TreeSet for shift indexes
        TreeSet<Integer> indexes = new TreeSet<Integer>(suffixCmp);
        for (int i = 0; i < size; i++) {
            indexes.add(i);
        }
        return indexes.toArray(new Integer[size]);
    }