Bubble sort is a simple sorting algorithm. The algorithm starts at the beginning of the data set. It compares the first two elements, and if the first is greater than the second, it swaps them.


The maximum number of operations that would have to be done in the worst case would be (n^2), where n is the number of lines to sort.

Code Simplified:

Source: GitHub

Inspiration and information source:

https://en.wikipedia.org/wiki/Sorting_algorithm#Bubble_sort