The ``if'' statement swaps adjacent elements A[i] and A[i+1] in the array if they are out of order.
The ``for'' loop, sweeps through the list swapping adjacent elements as it goes.
The ``while'' loop executes the ``for'' loop repeatedly until it makes no swaps.