Commit 99d80f8
authored
⚡️ Speed up function
Here’s the most efficient rewrite of your program:
- **Replace** the manual insertion sort (O(n²)) with Python’s built-in `.sort()` (Timsort, O(n log n) worst, very fast in practice—*and* stable/in-place!).
- **Preserve all outputs and the function signature.**
- The internal sort is now optimal for all reasonable inputs, no unnecessary copies or allocations.
**No other changes are necessary:**
- `.sort()` modifies the list in place and does so optimally.
- All function prints and return values are preserved.
This is the fastest way to sort a list in Python given your requirements.sorter by 32,451%1 parent 2185af9 commit 99d80f8
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