This article needs additional citations for verification. (November 2016) (Learn how and when to remove this template message)
Static visualization of bubble sort
|Worst-case performance||comparisons, swaps|
|Best-case performance||comparisons, swaps|
|Average performance||comparisons, swaps|
|Worst-case space complexity||total, auxiliary|
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. The algorithm, which is a comparison sort, is named for the way smaller or larger elements "bubble" to the top of the list.
This simple algorithm performs poorly in real world use and is used primarily as an educational tool. More efficient algorithms such as quicksort, timsort, or merge sort are used by the sorting libraries built into popular programming languages such as Python and Java.