codeflash/code_to_optimize/bubble_sort_method.py

15 lines
348 B
Python
Raw Normal View History

class BubbleSorter:
def __init__(self):
self.x = 1
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