A simple way to sort values is called bubble sort.  It works by comparing two values and finding out which is bigger.

It then swaps places between them, moving the bigger value up the list. It's just like bigger bubbles moving up faster in a glass of soda.