Below, you'll find a collection of examples illustrating the most basic, yet delightfully inefficient sorting algorithm.
Imagine a row of colorful, wobbly balls. Each ball represents a value, and the goal is to arrange them in order from smallest to largest.
Bubble sort works by repeatedly iterating through the row, comparing each ball to its neighbor, and "bubbling" the larger ones to the end.
View the algorithm in actionPicture a line of people waiting for coffee. Each person represents a value, and the goal is to arrange them in order from smallest to largest (i.e., shortest to tallest).
Bubble sort works by having each person compare themselves to their neighbor, and "moving" the larger ones to the end of the queue.
Read more about queue theoryLearn more about implementing bubble sort in code
Or, if you're feeling adventurous, read about common pitfalls and gotchas