Solution: Here are several solutions, first two that just use conditional execution to go through all the possibilities and then one that adapts the idea of bubble sort for this particular limited case.
Refer to assignment for description of problem.
Solution: Here is one solution: