public SortedMap<K, V> toSortedMapByKey(Comparator<K> keyComparator) {
        requireNonNull(keyComparator);
        return inner.collect(Collectors.toMap(
            Map.Entry::getKey,
            Map.Entry::getValue,
            throwingMerger(),
            () -> new TreeMap<>(keyComparator)
        ));
    }
Accumulates all key-value pairs of this {@code MapStream} into a 
{@code SortedMap}, sorting the entries by applying the specified
comparator to the keys of the stream.
<p>
If the mapped keys contains duplicates (according to
{@link Object#equals(Object)}), an {@code IllegalStateException} is
thrown when the collection operation is performed. If the mapped keys
may have duplicates, use {@link #toSortedMap(Comparator, BinaryOperator)}
instead.

<p>
The returned {@code Map} is not concurrent. For parallel stream
pipelines, use {@link #toConcurrentNavigableMap()} instead.

@param keyComparator  the comparator to use when sorting the keys
@return               a {@code SortedMap} whose keys and values are 
                      identical to the entries of this stream
@throws NullPointerException if any of the provided parameters are {@code null}

@see #toMap(BinaryOperator)
@see #toConcurrentMap()
@see #toSortedMap()
common-parent/mapstream/src/main/java/com/speedment/common/mapstream/MapStream.java