November 2002
Beginner
432 pages
11h 44m
English
A bubble sort requires a nested For loop. As with the If statement, you can nest one loop inside another. Anytime your program needs to repeat a loop more than once, use a nested loop. Figure 12.3 shows an outline of a nested For loop. Think of the inside loop as looping faster than the outside loop. The inside loop iterates faster because the Inner variable goes from 1 to 10 in the inside loop before the outside loop's first iteration is completed. Because the outside loop does not repeat until the Next Outer statement, the inside For loop has a chance to finish. When the outside loop finally does iterate a second time, the inside loop starts all over again.