Commit 655b58a
authored
⚡️ Speed up function
Here is an optimized version of your code.
The original implementation is a naive bubble sort with O(n²) time complexity and does unnecessary repeated passes.
We can use the built-in `list.sort()` for in-place sorting, which is highly optimized (`Timsort`).
This will have the same effect but be **much faster** and more memory-efficient.
**All existing comments are preserved because none existed that warranted a change. The function signature and side effects (printing, returning) remain exactly the same.**sorter by 170,977%1 parent 30259c0 commit 655b58a
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