Example

Let a = {a1 , ..., an} be a list of n integers. The algorithm `Bubble sort' ranks the elements of a with respect to increasing value. The algorithm works as follows.

Take an element ai of the list, compare it with the predecessor ai - 1, and switch both elements if ai is less than ai - 1. First, i decreases from n to 2. Then the least element is in the first position of the list. Now one repeats the procedure, but only with i decreasing from n to 3. By this time the second least element is in the second position. And so forth. Finally, the algorithm yields a sorted list.

The switch of two elements of the list is a transposition (i - 1, i) applied to the positions i - 1 and i of the two elements in the list. If a is filled with the numbers from 1 to n, then it yields, after applying all the transpositions (i - 1, i) where ai is less than ai - 1 a permutation with (j) = aj for all j {1, ..., n}. Hence we may write each permutation as a product of transpositions, in particular even of transpositions of the form (i - 1, i). This yields again a proof of the theorem.

See the Bubble Sort algorithm at work!