Manual Sort - Function

This is a function for sorting an array of numbers from smallest to
largest. It serves the same purpose as the much simpler formula:
array.sort(function(a,b){return a-b})

But I felt the need to construct the mechanism the long way just to
understand it, because truthfully, while I know how to USE the .sort
method, I don't really understand why it works the way it does.