
We can order the n numbers 1, 2, 3,..., n in n! different ways. Each of these n! orderings represents a different permutation of the numbers 1, 2, 3,..., n. For example, if n equals 3 we have 6 (=3·2·1) possible orderings: (1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2) and (3,2,1). The lexicographic permutation order starts from the identity permutation (1,2,..., n). By successively swapping only two numbers one obtains all possible permutations. The last permutation in lexicographic order will be the permutation with all numbers in reversed order, i.e. (n,n1,...,2,1). The example given above has all 6 permutations in lexicographic permutation order.
© djmw, January 31, 2014