Combinatorica`
Combinatorica`

NextPermutation

NextPermutation[p]

gives the permutation following p in lexicographic order.

Details and Options