swapped

fun <A, B> Pair<A, B>.swapped(): Pair<B, A>

Returns a new Pair with the components exchanged.

val (value, key) = (key to value).swapped()