/// <inheritdoc cref="Compare"/>
            public int compare(int[] c1, int[] c2)
            {
                if (c1.Length != k)
                {
                    throw new DimensionMismatchException(c1.Length, k);
                }
                if (c2.Length != k)
                {
                    throw new DimensionMismatchException(c2.Length, k);
                }

                // Method "lexNorm" works with ordered arrays.
                int[] c1s = MathArrays.copyOf(c1);
                Array.Sort(c1s);
                int[] c2s = MathArrays.copyOf(c2);
                Array.Sort(c2s);

                long v1 = lexNorm(c1s);
                long v2 = lexNorm(c2s);

                if (v1 < v2)
                {
                    return(-1);
                }
                else if (v1 > v2)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
        /// <inheritdoc/>
        /// <remarks>
        /// This method calls <see cref="MathArrays.shuffle(int[],RandomGenerator)"/>
        /// in order to create a random shuffle of the set
        /// of natural numbers <c>{ 0, 1, ..., n - 1 </c>}.
        /// </remarks>
        /// <exception cref="NumberIsTooLargeException"> if <c>k > n</c>.</exception>
        /// <exception cref="NotStrictlyPositiveException"> if <c>k <= 0</c>.</exception>
        public int[] nextPermutation(int n, int k)
        {
            if (k > n)
            {
                throw new NumberIsTooLargeException <Int32, Int32>(new LocalizedFormats("PERMUTATION_EXCEEDS_N"), k, n, true);
            }
            if (k <= 0)
            {
                throw new NotStrictlyPositiveException <Int32>(new LocalizedFormats("PERMUTATION_SIZE"), k);
            }

            int[] index = MathArrays.natural(n);
            MathArrays.shuffle(index, getRandomGenerator());

            // Return a new array containing the first "k" entries of "index".
            return(MathArrays.copyOf(index, k));
        }