distinctByKey

Returns a new sequence containing only the first occurrence of each key.

Example:

val sequence = sequenceOf(1, 1, 2).assertSorted()
val distinct = sequence.distinctByKey()
assertEquals(listOf(1, 2), distinct.toList())

Return

A new sorted sequence with duplicate keys removed