# Bubble Sort

> A simple sort that swaps neighbours until the list is in order. It is slow.

**Field:** Software Development  
**Category:** Algorithms & Data Structures  
**Also known as:** Sinking Sort

## Think of it like

Think of it like bubbles in a glass. The biggest ones float up to the top, one at a time.

## Definition

Bubble sort walks through a list again and again. It swaps any two neighbours that are in the wrong order. After each pass, the largest item left has bubbled to the end. It stops when a full pass makes no swaps. It takes O(n²) steps, so a list of 10,000 items needs about 100 million comparisons. It is mostly used to teach how sorting works.

## Example

Jack's class sorts five cards with bubble sort by hand. It takes four passes, and the 9 moves one place right each time.

## Why it matters

It is the first sort most people learn. It shows why speed matters.

## Common mistake

Using it on real data. A built-in sort is thousands of times faster on a big list.

## Three principles

- **Swap neighbours.** When out of order.
- **Pass after pass.** Until no swaps.
- **O(n²).** For teaching, not work.

## Related terms

- [Sorting Algorithm](https://learn.benibix.com/term/development/sorting-algorithm)
- [Merge Sort](https://learn.benibix.com/term/development/merge-sort)
- [Quicksort](https://learn.benibix.com/term/development/quicksort)
- [Big O Notation](https://learn.benibix.com/term/development/big-o-notation)
- [Insertion Sort](https://learn.benibix.com/term/development/insertion-sort)
- [Selection Sort](https://learn.benibix.com/term/development/selection-sort)

---

Source: https://learn.benibix.com/term/development/bubble-sort
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
