where \(\pi(1), \pi(2), \ldots, \pi(n)\) is any permutation of \(1, 2, \ldots, n\).

Proof

Consider a permutation \(\pi(1), \pi(2), \ldots, \pi(n)\) such that \(a_1b_{\pi(1)}+a_2b_{\pi(2)}+\ldots+a_nb_{\pi(n)}\) is maximized. The desired result is that \(\pi\) is the identity permutation; i.e. \(\pi(i)=i\) for all \(i\). Suppose for the sake of contradiction that \(\pi\) is not the identity, and let \(i\) be the smallest integer such that \(\pi(i) \neq i\).

Since \(i\) is the smallest such integer, this means that \(\pi(i)=j>i\) (as the numbers \(1\) to \(i-1\)) are already assigned. Furthermore, there must exists a \(k>i\) such that \(\pi(k)=i\), as some number must be assigned to \(i\).

Now, since \(i<j\), it follows that \(b_i \leq b_j\). Similarly, since \(i<k\), it follows that \(a_i \leq a_k\). Therefore
\[0 \leq (a_k-a_i)(b_j-b_i) \implies a_ib_j+a_kb_i \leq a_kb_j+a_ib_i\]
so the sum \(a_1b_{\pi(1)}+\ldots+a_nb_{\pi(n)}\) is not decreased by changing \(\pi(i)=j, \pi(k)=i\) to \(\pi(i)=i, \pi(k)=j\). This implies that the identity permutation gives the maximum possible value of \(a_1b_{\pi(1)}+a_2b_{\pi(2)}+\ldots+a_nb_{\pi(n)}\), as desired.

Strategies and Applications

The value of the rearrangement inequality lies chiefly in the fact that it formalizes one's intuition towards what amounts to a greedy algorithm. For instance, if one were presented with a large number of $20 bills, $10 bills, $5 bills, and $1 bills, with the instructions to take 4 of one type of bill, 3 of another, 2 of another, and 1 of the last, it is intuitively obvious that four $20 bills, three $10 bills, two $5 bills, and one $1 bill should be selected. Indeed, this is precisely the statement of the rearrangement inequality, applied to the sequences \(20, 10, 5, 1\) and \(4, 3, 2, 1\).

Like the Chebyshev inequality, care must be taken to assure both sequences are similarly ordered. Common strategies include: