KT-20357 Add sortedBy() sample (#3283)

This commit is contained in:
Dmitry Borodin
2020-05-19 18:21:21 +02:00
committed by GitHub
parent 0d71758112
commit 1a0b59da49
5 changed files with 32 additions and 1 deletions
@@ -533,6 +533,8 @@ public fun <T : Comparable<T>> Sequence<T>.sorted(): Sequence<T> {
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*
* The operation is _intermediate_ and _stateful_.
*
* @sample samples.collections.Collections.Sorting.sortedBy
*/
public inline fun <T, R : Comparable<R>> Sequence<T>.sortedBy(crossinline selector: (T) -> R?): Sequence<T> {
return sortedWith(compareBy(selector))