The algorithm in use is selection sort [wikipedia.org]. It's one of the simplest sorting techniques.
It's algorithm is:
1. Find the smallest element in an unsorted array.
2. Swap it with the value at the first position for the current iteration.
3. Repeat this procedure n-1 times. (n being the no of elements in the array)
If you have trouble understanding the algorithm, check out the animation in the wikipedia link posted above.
To answer your questions:
-The outer for loop is there to accomplish the third step in the algorithm.
-At the start of each iteration, you assign the topmost element for the current iteration to m(this variable holds the minimum value in the array for the current iteration)
-The inner loop scans the rest of the array and tries to see if there are elements with smaller values than what has already been assigned to 'm'.
-If there are such elements, we place it in 'm' since it holds the value of the smallest element.
-After finding the least element, we place it at the top of the unsorted part of the array(that is, the position pointed to by the outer loop)