I have one simple array like:
var cellOrder = [1,2,3,4]
I want to exchange elements like suppose a second element with first element.
A
Use swap:
swap
var cellOrder = [1,2,3,4] swap(&cellOrder[0], &cellOrder[1])
Alternately, you can just assign it as a tuple:
(cellOrder[0], cellOrder[1]) = (cellOrder[1], cellOrder[0])