swapped

fun <T> List<T>.swapped(index1: Int, index2: Int): List<T>

Returns a shallow copy of this list with the items at index1 and index2 swapped. Throws IndexOutOfBoundsException when one or both indices are not present in the collection