Bubble sort
To understand how Bubble Sort works, consider an array containing
elements to be sorted. We look through the array and pick
the smallest element and put it in position 1. That is the first pass.
We look through the remaining list from the second element to the
last and pick the smallest and put in position 2 and so on until all
the elements are sorted. Consider the array of numbers below for
instance:
8 4 3 2
Figure 1 gives a pictorial representation of how the sorting will be
done.
Refinements on bubble sort