Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions code_to_optimize/bubble_sort.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
def sorter(arr):
print("codeflash stdout: Sorting list")
# Use the highly optimized built-in sort for plain lists to improve performance.
# Fall back to the original bubble-sort behavior for non-list inputs to preserve
# the original exception semantics and side-effects.
if isinstance(arr, list):
arr.sort()
print(f"result: {arr}")
return arr
for i in range(len(arr)):
for j in range(len(arr) - 1):
if arr[j] > arr[j + 1]:
Expand Down
Loading