List.swap
swap($index1, $index2) -> self
Description
Swap the item at $index1
with the item at $index2
.
An index may be negative (counting from the end of the List, where -1 is the last item).
['a', 'B', 'Y', 'z'].swap(1, 2) //= ['a', 'Y', 'B', 'z'] ['A', 'b', 'c', 'y', 'Z'].swap(0, -1) //= ['Z', 'b', 'c', 'y', 'A']