wx report

Sort algorithms

Simon made a nice picture of seven sort algorithms. He added Python’s Timsort. It made me want to review what Timsort did, and I learned that it was way more involved than I remembered; I had thought it was “only” quicksort wrapped with “detect and preserve already-sorted runs”. I also learned that it’s been replaced in Python by a thing called Powersort (by which I mean that if you have a Python list called my_fancy_list then the Powersort algorithm is used by my_fancy_list.sort() to rearrange the list elements in order).

So I asked Claude to add Powersort to the algorithm visualizer, and the completely weird Shellsort while I was at it, and I added a “Code” button at the bottom that shows you the javascript code for each sort algorithm, and here is the result. “Run all” is the funnest thing here.

50
60
Comparisons 0
Swaps 0
Status Ready
Comparing
Swapping
Pivot
Sorted
Active run

All algorithms racing

50
85
Comparing
Swapping
Pivot
Sorted
Active run