Put element as the first in the list
By somaria
2022-10-10
fun main() { //define a list of 3-letter months from Jan to Jun val months = listOf("Jan", "Feb", "Mar", "Apr", "May", "Jun") //put "May" as the first element of the list val months2 = months.toMutableList() months2.add(0, months2.removeAt(4)) println(months2) }

Output

[May, Jan, Feb, Mar, Apr, Jun]