assert Sorted By
fun <TKey : Comparable<TKey>, TValue> Sequence<TValue>.assertSortedBy(sortOrder: SortOrder = ASCENDING, keySelector: (TValue) -> TKey): SortedSequence<TKey, TValue>
Creates a SortedSequence from this sequence, asserting that elements are sorted by the given key selector.
Example:
val sequence = sequenceOf("az", "by", "cx").assertSortedBy { it.first() }
assertEquals(listOf("az", "by", "cx"), sequence.toList())
Content copied to clipboard
Return
A sorted sequence wrapper
Parameters
TKey
The type of keys in the sequence, must be comparable
TValue
The type of values in the sequence
sort Order
The sort order to verify against (default: ASCENDING)
key Selector
Function that extracts the sorting key from each element