Bubble sort
Bubble sort is another simple algorithm that steps through the list of values or objects to be sorted and compares adjacent items or their keys to determine if they are in the wrong order. The name comes from the way that unordered items seem to bubble to the top of the list. However, some developers sometimes refer to this as a sinking sort, as objects could just as easily appear to be dropping down through the list.
Overall, the bubble sort is just another inefficient comparison sort. However, it does have one distinct advantage over other comparison sorts, in that: inherently determine whether or not the list has been sorted. Bubble sort accomplishes this by not performing comparisons on objects that were sorted in previous iterations and by stopping once the collection proves ordered.
For example, consider the case of ordering a collection in ascending order. A bubble sort algorithm will examine an object at index i and determine if its key is lower in value or priority than...