Sorting is a way to rearrange or reorder a data in ascending or descending order. Sometimes we need to sort a data to process it quickly or use it efficiently.
Bubble sort is one of the simplest and easiest sorting algorithms to sort data items stored in a data structure like list. Bubble sort works by comparing all the elements with their adjacent elements one by one and sort them based on their values.
In bubble sort, sorting takes place by comparing adjacent data items one by one and swapping each pair that is out of order.
This algorithm is called bubble sort, because with each iteration the largest data item in the list bubbles up towards the last place in the list, just like a water bubble rises up to the water surface.
In this article, We will understand bubble sort in python with its working. We will also see python code for bubble sort.