Sorting is a very important problem in computer science. A well known conclusion is that good sorting algorithms run with a time-complexity of . That is if the sorting is based on pair-wise comparison of objects. The neat thing is that we can proof that any sorting algorithm based on pair-wise comparisons runs in time.

When we say “based only on pair-wise comparison of objects” we mean that we do not use the values of the objects directly. We only use a comparator, a function of the form: the same conclusions hold if the comparator gives a special value if .

## Proof

Consider an arbitrary list for witch every is comparable to every other for all and . We know that there are possible permutations of the list.

A program that sorts arbitrary lists, should be able to apply any of the permutations of the list. If this would not be the case, one could easily construct a list that the algorithm can’t sort. Namely the result of applying the inverse permutation to .

Note that the permutation that the algorithm can do depend only on the values of the list, since this is the only input. our program can only gather information from the list by doing pair-wise comparisons. Let’s call the number of comparisons the the algorithm does . Given comparisons, we can have different outcomes. There are possible permutations that the algorithm should do. Thus we need:

or by taking the of both sides (note that both sides are positive integers):

Let’s look at a little closer:

We make a lower bound by cutting off the terms after :

Thus we have:

Or