sortedBy

fun <T, R : Comparable<R>> Sequence<T>.sortedBy(ordering: Ordering, comparator: <Error class: unknown class><in R>? = null, selector: (T) -> R?): Sequence<T>

Sorts elements by a selector value in the given ordering.

null values are always sorted first, regardless of the ordering.

Return

a new sequence with elements sorted according to the selector and ordering

Parameters

ordering

whether to sort in ascending or descending order

Values

comparator
  • Optional

optional additional comparator to use for comparing the selected values

selector

function that extracts a comparable value from each element