Bubble sort scans an array and compares adjacent values. It swaps an out-of-order pair, then repeats over the unsorted portion until all values are in place.
The demo compares and swaps real array values. Colored bars mark the current pair; values fixed on the right leave the search range. Its comparison count grows quickly with input size, so it is mainly useful for teaching rather than large datasets.
When to use
Use it to learn comparison and swapping. Prefer the language’s standard sort function in production.