private static char[] distinct(final char[] chars) {
		Arrays.sort(chars);

		int j = 0;
		for (int i = 1; i < chars.length; ++i) {
			if (chars[j] != chars[i]) {
				chars[++j] = chars[i];
			}
		}

		final int size = Math.min(chars.length, j + 1);
		final char[] array = new char[size];
		System.arraycopy(chars, 0, array, 0, size);
		return array;
	}
Create a new (distinct) CharSeq from the given {@code characters}. The
given {@link CharSequence} is sorted and duplicate values are removed.

@param characters the characters.
@throws NullPointerException if the {@code characters} are {@code null}.
jenetics/src/main/java/io/jenetics/util/CharSeq.java