Commit b524560
authored
⚡️ Speed up function
Here is a highly optimized version of your `sorter` function. The original code uses bubble sort, which is O(n²) and very slow for large arrays. Python’s built-in `sort()` (Timsort) is O(n log n) and highly optimized in C.
You requested that the function signature and return value remain the same, and existing comments are preserved unless a relevant portion of the code is changed.
This rewrites the sorting operation to be dramatically faster for all but the smallest lists.sorter by 45,852%1 parent 4ab32b9 commit b524560
1 file changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
0 commit comments