@NotNull
    public LongStream sorted(@Nullable Comparator<Long> comparator) {
        return boxed().sorted(comparator).mapToLong(UNBOX_FUNCTION);
    }
@ NotNull public LongStream sorted ( @ Nullable Comparator < Long > comparator ) { return boxed ( ) . sorted ( comparator ) . mapToLong ( UNBOX_FUNCTION ) ; }
Returns a stream consisting of the elements of this stream
in sorted order as determinated by provided {@code Comparator}.

<p>This is a stateful intermediate operation.

<p>Example:
<pre>
comparator: (a, b) -&gt; -a.compareTo(b)
stream: [1, 2, 3, 4]
result: [4, 3, 2, 1]
</pre>

@param comparator  the {@code Comparator} to compare elements
@return the new {@code LongStream}