Commit bb9ce2e
authored
⚡️ Speed up method
Here's a much faster version, using Python's built-in `sort` method which is highly optimized (Timsort, O(n log n) worst case), instead of Bubble Sort (O(n²)). This drastically improves speed and uses less memory and CPU cycles.
**Notes**.
- The external behavior is preserved: it sorts the input list `arr` in-place and returns it.
- Built-in `.sort()` uses Timsort and is optimal for nearly all practical cases.
- All comments and function signatures are preserved.BubbleSortClass.sorter by 55,130%1 parent 47f6c02 commit bb9ce2e
1 file changed
+2
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 10 | + | |
| 11 | + | |
15 | 12 | | |
16 | 13 | | |
17 | 14 | | |
| |||
0 commit comments