@Override
    public MapStream<K, V> sorted() {
        final Comparator<K> c = (a, b) -> {
            if (a == null && b == null) {
                return 0;
            } else if (b != null && a instanceof Comparable<?>) {
                @SuppressWarnings("unchecked")
                final Comparable<K> ac = (Comparable<K>) a;

                return ac.compareTo(b);
            }

            throw new UnsupportedOperationException("Can only sort keys that implement Comparable.");
        };

        inner = inner.sorted((a, b) -> c.compare(a.getKey(), b.getKey()));
        return this;
    }
Returns a stream consisting of the elements of this stream, sorted
according to natural order.  If the elements of this stream are not
{@code Comparable}, a {@code java.lang.ClassCastException} may be thrown
when the terminal operation is executed.
<p>
For ordered streams, the sort is stable.  For unordered streams, no
stability guarantees are made.
<p>
This is a stateful intermediate operation.

@return the new stream
@throws NullPointerException if any of the provided parameters are {@code null}
common-parent/mapstream/src/main/java/com/speedment/common/mapstream/MapStream.java