Permutation: Previous

Get the previous permutation in lexicographic permutation order. The previous permutation is obtained from the selected permutation by swapping values at only two positions. If no further permutation is available, i.e. the current permutation is at the lexicographic start position (1, 2, 3, ..., n-1, n), the current permutation will not change anymore.

The Previous operation follows the opposite order of Permutation: Next.