diff --git a/code_to_optimize/bubble_sort.py b/code_to_optimize/bubble_sort.py index 787cc4a90..f01dd4a14 100644 --- a/code_to_optimize/bubble_sort.py +++ b/code_to_optimize/bubble_sort.py @@ -1,10 +1,8 @@ def sorter(arr): 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] - arr[j] = arr[j + 1] - arr[j + 1] = temp + + # Using the built-in sort method which is more efficient + arr.sort() + print(f"result: {arr}") - return arr \ No newline at end of file + return arr