Bubble Sort

Buuble sort is a simple sorting algorithm in which the adjacent elements are swapped when they are not in order based on the user's preference(acsending/desceding) .If we have to sort n elements  there are two full loops(from initial position to final position) so thats why It's complexity for both the average and worst case is O(n^2) which is why most of the programmers don't use.

A pseudo code for ascending order sorting is:-

begin BubbleSort(list)

   for all elements of list
      if list[i] > list[i+1]
         swap(list[i], list[i+1])
      end if
   end for
   return list
end BubbleSort