reactor-core/src/main/java/reactor/core/publisher/Flux.java
@SuppressWarnings({ "unchecked", "rawtypes" })
	public final Mono<List<T>> collectSortedList(@Nullable Comparator<? super T> comparator) {
		return collectList().map(list -> {
			// Note: this assumes the list emitted by buffer() is mutable
			if (comparator != null) {
				list.sort(comparator);
			} else {

				List<Comparable> l = (List<Comparable>)list;
				Collections.sort(l);
			}
			return list;
		});
	}
@SuppressWarnings({ "unchecked", "rawtypes" })
	public final Mono<List<T>> collectSortedList(@Nullable Comparator<? super T> comparator) {
		return collectList().map(list -> {
			// Note: this assumes the list emitted by buffer() is mutable
			if (comparator != null) {
				list.sort(comparator);
			} else {

				List<Comparable> l = (List<Comparable>)list;
				Collections.sort(l);
			}
			return list;
		});
	}
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public final Mono < List < T > > collectSortedList ( @ Nullable Comparator < ? super T > comparator ) { return collectList ( ) . map ( list -> { // Note: this assumes the list emitted by buffer() is mutable if ( comparator != null ) { list . sort ( comparator ) ; } else { List < Comparable > l = ( List < Comparable > ) list ; Collections . sort ( l ) ; } return list ; } ) ; }
Collect all elements emitted by this {@link Flux} until this sequence completes,
and then sort them using a {@link Comparator} into a {@link List} that is emitted
by the resulting {@link Mono}.

<p>
<img class="marble" src="doc-files/marbles/collectSortedListWithComparator.svg" alt="">

@reactor.discard This operator discards the buffer upon cancellation or error triggered by a data signal.

@param comparator a {@link Comparator} to sort the items of this sequences

@return a {@link Mono} of a sorted {@link List} of all values from this {@link Flux}
Collect all elements emitted by this { @link Flux } until this sequence completes and then sort them using a { @link Comparator } into a { @link List } that is emitted by the resulting { @link Mono } .