How many slots?

Basic Sorting with BubbleSort

Putting lists (arrays) of elements into order is an important category of program. This program does this using a very inefficient sort called Bubble Sort.

We start with an array loaded with random integers between 0 and 1000. We repeatedly "bubble" the largest element up to the end of that array. After doing this "bubbling" over and over we eventually get the entire array into order.


The user provides a single positive integer on the HTML page in a text box. This number tells how many random integers to generate into an array.


The program prints the original array of random integers, then prints the array elements in sorted order.


The program ends on its own.