Bubble sort, sometimes referred to as sinking sort, is a simple Sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted.

[links added]

Bubble sort is stable.

## Algorithm

```
while list is not sorted do
for i in range(len(list) - 1) do
if list[i] > list[i+1] do
swap(i, i+1)
```

## Implementation

## Complexity

Worst-case | Best-case | |
---|---|---|

Time | \(O(n^2)\) | \(O(n)\) |

Space | \(O(n)\) | \(O(n)\) |

## Bibliography

“Bubble Sort.” 2022.

*Wikipedia*, June. https://en.wikipedia.org/w/index.php?title=Bubble_sort&oldid=1093592571.