We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b8f1c7c commit 2959bb3Copy full SHA for 2959bb3
code_to_optimize/bubble_sort.py
@@ -1,7 +1,10 @@
1
-import sys
2
-
3
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
+ print("codeflash stdout: Sorting list")
+ for i in range(len(arr)):
+ for j in range(len(arr) - 1):
+ if arr[j] > arr[j + 1]:
+ temp = arr[j]
7
+ arr[j] = arr[j + 1]
8
+ arr[j + 1] = temp
9
+ print(f"result: {arr}")
10
return arr
0 commit comments