Commit 875ef2f
authored
⚡️ Speed up function
Here is an optimized version of your program. The original uses a naive bubble sort (`O(n^2)`); using Timsort (the built-in `sorted` or `list.sort()`, which is `O(n log n)`) is much faster for all but the smallest lists. I've preserved output, function signature, and return value.
This is much faster and uses less memory than making a new list or reimplementing a sort.sorter by 217,337%1 parent 0332d2b commit 875ef2f
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