Bubble sort is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items, and swapping them if they are in the wrong order. This process is repeated until no swaps are needed, indicating that the list is sorted.
The algorithm gets its name because smaller elements "bubble" to the top of the list (beginning), while larger elements "sink" to the bottom (end) with each pass.
During the sorting algorithm, the total count of swapping action is the number of the inversions in the original list.