Skip to content

Commit 62e2551

Browse files
⚡️ Speed up function sorter by 30,125%
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).
1 parent 97f70aa commit 62e2551

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def sorter(arr):
2+
arr.sort()
3+
return arr

0 commit comments

Comments
 (0)