Let's implement the Bubble sorting algorithm using python .

Bubble sort is an algorithm that compares the adjacent elements and swaps their positions if they are not in the intended order. The order can be ascending or descending.

This code sort the list in ascending order, to get the output in descending order change the code in this line.Change > to <
if array[j] < array[j+1]:

To run open terminal and hit

$ python bubble_sort.py  

Sample Input :

$ python bubble_sort.py 
1 3 4 2     

Sample Output :

[1, 2, 3, 4]    

This is my explanation in implementing bubble sort in python . if you have any better idea or suggestion, please let me know in the comment below.