codeflash/code_to_optimize/bubble_sort_method.py
2025-03-03 16:59:17 -08:00

13 lines
408 B
Python

class BubbleSorter:
def __init__(self, x=0):
self.x = x
def sorter(self, arr):
print("codeflash stdout : BubbleSorter.sorter() called")
for i in range(len(arr)):
for j in range(len(arr) - 1):
if arr[j] > arr[j + 1]:
temp = arr[j]
arr[j] = arr[j + 1]
arr[j + 1] = temp
return arr