codeflash/code_to_optimize/bubble_sort_method.py
2025-01-21 16:22:38 -08:00

12 lines
343 B
Python

class BubbleSorter:
def __init__(self, x=0):
self.x = x
def sorter(self, arr):
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