Permutation: Swap positions...

Swaps the contents at two indices in the selected Permutation.


First index, Second index
the two indices from where elements have to be swapped. The order of these indices is not important.


With First index = 1 and Second index = 3, the permutation (1,3,4,2,5) is turned into (4,3,1,2,5).

© djmw, January 5, 2011