"They laughed when I sat down at the keyboard and coded the bubbles ..."
But seriously: Bubblesort is close, but not quite. Bubblesort repeatedly moves in the same direction, therefore, if there is a small value near the upper end of the array, and the comparison site “bubbles up” all the time, many iterations of the main loop are required for the data element to go downstream. This is a very worst behavior that is disastrous for Bubblesort.
But there is a clarification for BubbleSort, sometimes called the Elevator Cocktail Sort, where the bubble moves in alternating directions: one skip, one pass down, repeat. This allows individual elements to move long distances in one pass (or, in fact, 2 passes), and the number of passes is proportional to the number of elements that need to be moved. For a small amount of unsorted items, this may come close to efficiency.
I believe that for the general case, the second link in the answer will be faster. The advantage of Bubble / Elevator Cocktail sorting is that it is so simple, it is almost flawless, and not much work.
source share