move

fun <T> MutableList<T>.move(from: Int, to: Int)

Moves an element within the mutable list from one index to another. If the from and to indices are the same, no operation is performed.

Parameters

from

The index of the element to move. Must be a valid index within the list.

to

The target index where the element should be moved. Must be a valid index within the list.


fun <T> MutableList<T>.move(from: IntRange, to: Int)

Moves a sublist defined by the specified range of indices to a new position within the mutable list.

Parameters

from

the range of indices that defines the source elements to be moved. The start index and end index of the range are inclusive.

to

the target index where the sublist will be inserted. The index must not overlap with the source range.