Live data from Hacker News

Timsort, the Python sorting algorithm

skerritt.blog

1–10 of 135 posts

Re: Timsort, the Python sorting algorithm

#4
I heard of it from a talk about a bug in the implementation of TimSort in several popular libraries [1]. That bug should be fixed in Java, Android and Python.

If you're using another language, you might want to verify that the bug is fixed/not present in your library

[1] http://www.envisage-project.eu/proving-android-java-and-pyth...

Re: Timsort, the Python sorting algorithm

#8
post #7

Note that Timsort uses O(n) extra space: sometimes this can be undesirable.

Note that this is true for any (edit: stable, nlogn) merge sort.

Not true in general, however IIRC it is the case if you want optimal (i.e. n log n) time complexity.

Re: Timsort, the Python sorting algorithm

#10
post #8
post #7

Earlier quoted context omitted.

Note that this is true for any (edit: stable, nlogn) merge sort.

Not true in general, however IIRC it is the case if you want optimal (i.e. n log n) time complexity.

Not even in that case. Heapsort guarantees worst case n log n, and so does quicksort if you use an O(n) median selecting algorithm.

Stable sorts often do require that, (mergesort is usually stabble, heapsort and quicksort are inherently not), but even that's not required - there is a completely in-place variant of merge sort that only requires O(log n) space for stack (like quicksort; heapsort is O(1)). See e.g. https://xinok.wordpress.com/2014/08/17/in-place-merge-sort-d...

Post reply on HN