distinctByKey

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

Example:

val sequence = sequenceOf(1 to "a", 1 to "b", 2 to "c").assertSorted()
val distinct = sequence.distinctByKey()
assertEquals(
listOf(
1 to "a",
2 to "c"
),
distinct.toList()
)

Return

A new sorted sequence with duplicate keys removed