swap

fun <E> MutableList<E>.swap(i: Int, j: Int)

Swap values between elements at i and j.

Usage example:

mutableListOf(1, 2, 3).apply{ swap(0, 2) } // 3, 2, 1