sswift's code will be plenty fast, but you did ask for the fastest which would be a 4 element version of QuickSort...
Quicksort works by splitting the data set into halfs recursively and sorting each half. Eventually everything is sorted as the recursion pops back up the stack.
so ...
compare (1) and (2) and sort them (i.e. swap if necessary)
compare (3) and (4) and sort them
then compare (2) and (3) and sort them.
everything now sorted.
Quicksort works by splitting the data set into halfs recursively and sorting each half. Eventually everything is sorted as the recursion pops back up the stack.
so ...
compare (1) and (2) and sort them (i.e. swap if necessary)
compare (3) and (4) and sort them
then compare (2) and (3) and sort them.
everything now sorted.