I am following the proof given by on this [link](https://www.youtube.com/watch?v=PBhv1aXJOy4). So given two non-decreasing sequences $$ a\_1\leq a\_2\leq a\_3......\leq a\_n \\ b\_1\leq b\_2\leq b\_3......\leq b\_n.$$ Let, $(a'\_1,.... a'\_n)$ be a permutation of $(a\_1,.... a\_n)$. Then the following inequality holds: $a\_1b\_1+.....+a\_nb\_n\geq a'\_1b\_1+.....+a'\_nb\_n.$

**Proof**: Consider the sum $S=a\_1b\_1+..+a\_rb\_r+..+a\_sb\_s..+a\_nb\_n$ and $S'=a\_1b\_1+..+a\_sb\_r+..+a\_rb\_s..+a\_nb\_n.$ Now on taking the difference $S-S'$ we observe that $S-S'\geq0.$ After this, the person in the video says that since every permutation is a sequence of transpositions and therefore the sum $S$ is maximal. I understand this statement intuitively, but if I were to write formally (say, in an exam) how should I go about proving the theorem after I have shown that $S\geq S'.$