@Override
	public int compare(final int[] a, final int[] b) {
		if (a.length != b.length) {
			throw new IllegalArgumentException(
				"a and b have different size: %d != %d."
					.formatted(a.length, b.length)
			);
		}
		if (a.length != k) {
			throw new IllegalArgumentException(
				"Invalid array size: %d != %d.".formatted(a.length, k)
			);
		}
		for (int i = 0; i < k; ++i) {
			if (a[i] < 0 || a[i] >= n || b[i] < 0 || b[i] >= n) {
				throw new IllegalArgumentException(
					"a=%s or b=%s not part ot %s.".formatted(
						Arrays.toString(a),
						Arrays.toString(b),
						this
					)
				);
			}
		}

		for (int i = 0; i < k; ++i) {
			if (a[i] < b[i]) {
				return -1;
			} else if (a[i] > b[i]) {
				return 1;
			}
		}

		return 0;
	}
Compares two k-subset elements according its natural order.
{@snippet class="CombinatorialSnippets" region="KSubset.compare"}

@param a the first object to be compared.
@param b the second object to be compared.
@return a negative integer, zero, or a positive integer as the
        first argument is less than, equal to, or greater than the
        second.
@throws IllegalArgumentException if {@code !contains(a) || !contains(b)}
jenetics.incubator/src/main/java/io/jenetics/incubator/combinatorial/KSubset.java