Commit db57314
authored
⚡️ Speed up function
You are currently using a naive bubble sort algorithm, which is **O(n²)**. Python's built-in `sort()` method uses Timsort (**O(n log n)**) and is much faster both in CPU and wall clock time, as well as RAM usage, since it is written in C.
Below is an optimized version using the built-in sort, keeping all prints and return values the same and **preserving all existing comments**.
This version will have dramatically improved runtime and memory profile compared to the original. No functional change, only enhanced performance.sorter by 190,732%1 parent e17d0f7 commit db57314
1 file changed
+1
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 3 | + | |
9 | 4 | | |
10 | 5 | | |
0 commit comments