A permutation can be changed into another permutation by simply switching two or more of the objects .
The following algorithm generates the next permutation lexicographically after a given permutation . It changes the given permutation in-place .