Bubble Sort

A simple but inefficient algorithm that compares each element to its next neighbor and swaps their position if they are out of order. Bubble sort is fast and efficient if a list is already sorted or nearly sorted, running at O(n) in the best case; generally it is inefficient as it has no way to avoid repeating checks on elements that have been processed already, and runs at O(n^2).