Skip to content

Commit

Permalink
⚡️ Speed up function sorter by 30,125%
Browse files Browse the repository at this point in the history
The given code is implementing the bubble sort algorithm, which is not optimal for sorting. We can significantly increase the speed of this function by switching to a more efficient sorting algorithm like Timsort, which is the default sorting algorithm used in Python. Here's the optimized version.

 

This utilizes Python's built-in `sort` method, which is highly efficient with a time complexity of O(n log n).
  • Loading branch information
codeflash-ai-dev[bot] authored Dec 14, 2024
1 parent 97f70aa commit 489d42c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cli/code_to_optimize/bubble_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def sorter(arr):
arr.sort()
return arr

0 comments on commit 489d42c

Please sign in to comment.