kristofdho
12/16/2017, 12:36 PMfun <T> List<T>.swap(index1: Int, index2: Int): List<T> = toMutableList().also { it.swap(index1, index2) }
fun <T> MutableList<T>.swap(index1: Int, index2: Int) {
val tmp = this[index1]
this[index1] = this[index2]
this[index2] = tmp
}