2025-02-21 08:18:37 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
2025-01-21 20:34:19 +00:00
|
|
|
class BubbleSorter:
|
2025-01-22 00:22:38 +00:00
|
|
|
def __init__(self, x=0):
|
|
|
|
|
self.x = x
|
2025-01-21 20:34:19 +00:00
|
|
|
|
|
|
|
|
def sorter(self, arr):
|
2025-02-21 00:41:17 +00:00
|
|
|
print("codeflash stdout : BubbleSorter.sorter() called")
|
2025-01-21 20:34:19 +00:00
|
|
|
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
|
2025-02-21 08:18:37 +00:00
|
|
|
print("stderr test", file=sys.stderr)
|
2025-01-21 20:34:19 +00:00
|
|
|
return arr
|
2025-11-06 21:57:50 +00:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def sorter_classmethod(cls, arr):
|
|
|
|
|
print("codeflash stdout : BubbleSorter.sorter_classmethod() 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
|
|
|
|
|
print("stderr test classmethod", file=sys.stderr)
|
|
|
|
|
return arr
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sorter_staticmethod(arr):
|
|
|
|
|
print("codeflash stdout : BubbleSorter.sorter_staticmethod() 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
|
|
|
|
|
print("stderr test staticmethod", file=sys.stderr)
|
2025-11-06 22:04:12 +00:00
|
|
|
return arr
|