Skip to content

Commit 2959bb3

Browse files
committed
restore bb
1 parent b8f1c7c commit 2959bb3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

code_to_optimize/bubble_sort.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import sys
2-
31
def sorter(arr):
4-
sys.stdout.write("codeflash stdout: Sorting list\n") # Faster than print()
5-
arr.sort() # already optimal
6-
sys.stdout.write(f"result: {arr}\n") # Minimize print overhead
2+
print("codeflash stdout: Sorting list")
3+
for i in range(len(arr)):
4+
for j in range(len(arr) - 1):
5+
if arr[j] > arr[j + 1]:
6+
temp = arr[j]
7+
arr[j] = arr[j + 1]
8+
arr[j + 1] = temp
9+
print(f"result: {arr}")
710
return arr

0 commit comments

Comments
 (0)