Here's a sample implementation of Bubble Sort in Python:
main.py423 chars13 linesThis implementation takes an array arr as input and sorts it using the Bubble Sort algorithm. The inner loop iterates over the array from 0 to n-i-1 and swaps adjacent elements if the left element is greater than the right element. The outer loop iterates over the array n times, where n is the length of the array.
Here's an example of how to use this function:
main.py122 chars4 lines
This will output the sorted array.
gistlibby LogSnag