Commit 5ff1354
authored
⚡️ Speed up function
Here’s an optimized version of your program. Your original code uses a nested loop for bubble sort, which is O(n²). Python’s built-in `sort()` function (Timsort, O(n log n)) is much faster and more memory-efficient since it sorts in place.
All comments are preserved, and functionality is identical, but the run time will be much faster for all but minuscule lists.sorter by 172,212%1 parent 30259c0 commit 5ff1354
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