TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Timsort (2019)

189 pointsby akbarnamaalmost 3 years ago

14 comments

linsomniacalmost 3 years ago
Among the previous discussions of timsort:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21196555" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21196555</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17436591" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17436591</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17436591" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17436591</a>
评论 #32282099 未加载
评论 #32279661 未加载
Beldinalmost 3 years ago
Interestingly, Timsort used to be broken [1]. They found that by trying to prove correctness. I recall Stijn de Gouw remarking that they wanted to have their proof artefact evaluated, but you&#x27;d need a seriously beefy machine to do so.<p>[1] <a href="http:&#x2F;&#x2F;www.envisage-project.eu&#x2F;proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.envisage-project.eu&#x2F;proving-android-java-and-pyth...</a>
评论 #32281554 未加载
评论 #32282606 未加载
CJeffersonalmost 3 years ago
Closely related is pattern defeating quicksort ( <a href="https:&#x2F;&#x2F;github.com&#x2F;orlp&#x2F;pdqsort" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;orlp&#x2F;pdqsort</a> ), which adapts quicksort to take advantage of sorted runs. I&#x27;ve adapted a few quicksorts to pdqsort and seen good speedups (as people were often sorting partially sorted data)<p>Basically: Timsort is to mergesort as pdqsort is to quicksort
评论 #32282384 未加载
评论 #32281612 未加载
gavinrayalmost 3 years ago
I thought it was widely known, IIRC a number of languages have adopted it as the stdlib default sorting algorithm for either unstable&#x2F;stable sort (can&#x27;t remember which is it?)<p>I&#x27;m not big into algorithms but I believe that pdqsort and timsort were supposed to be the best two general sorts.
评论 #32280289 未加载
评论 #32280274 未加载
评论 #32281841 未加载
评论 #32282043 未加载
earthicusalmost 3 years ago
Here [1] is a great (short, readable) paper from 2015 that explains Timsort and similar stack-merge sorting algorithms. It also gives a runtime analysis, and a simplified version of the algorithm that they call &#x27;alpha-sort&#x27;.<p>[1] <a href="https:&#x2F;&#x2F;hal-upec-upem.archives-ouvertes.fr&#x2F;hal-01212839&#x2F;file&#x2F;merge_strategies.pdf" rel="nofollow">https:&#x2F;&#x2F;hal-upec-upem.archives-ouvertes.fr&#x2F;hal-01212839&#x2F;file...</a>
acrophiliacalmost 3 years ago
Whenever there&#x27;s a discussion about sorting I like to put in a little reminder about the humble Radix Sort which is often overlooked by academics because it&#x27;s so simple. It deserves more attention as it is super fast: O(kn). Academics disregard it because it won&#x27;t sort floating point numbers, but the vast majority of real-world use cases deal with alphanumerics, so Radix Sort should get more press than it does.
评论 #32287415 未加载
threatofrainalmost 3 years ago
Also interesting is pdqsort, which will become Go&#x27;s standard sort.<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31106157" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31106157</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31098822" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31098822</a>
Rapzidalmost 3 years ago
Needs a 2005 in the title.
lupirealmost 3 years ago
9 lines of Timsort was the centerpiece of the Oracle-Google Android Java lawsuit.<p><a href="https:&#x2F;&#x2F;www.infoq.com&#x2F;news&#x2F;2012&#x2F;05&#x2F;nine-lines&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.infoq.com&#x2F;news&#x2F;2012&#x2F;05&#x2F;nine-lines&#x2F;</a>
jsnkalmost 3 years ago
I was hoping to see some benchmark numbers
评论 #32280741 未加载
评论 #32280647 未加载
tpoacheralmost 3 years ago
&gt; built for the real world — not constructed in academia.<p>Why would lacking in evidence and rigor be considered a plus?<p>Does Timsort pride itself of being the homeopathy of sorting algorithms?<p>What a bizzare brag to make.
评论 #32281643 未加载
评论 #32281312 未加载
评论 #32281467 未加载
pizlonatoralmost 3 years ago
“you’ve never heard of” is a bit presumptuous. I’ve heard of it a lot, nothing but good things.
评论 #32280917 未加载
评论 #32280942 未加载
评论 #32282092 未加载
2143almost 3 years ago
It&#x27;s well known.<p>Nevertheless, the article was good.<p>If the author is reading this, consider dropping the &quot;you&#x27;ve never heard of&quot; from the title; you don&#x27;t want to assume things about your reader.
评论 #32280638 未加载
评论 #32280788 未加载
评论 #32281297 未加载
评论 #32282116 未加载
dktalksalmost 3 years ago
This blog steals content from other sites, original is at <a href="https:&#x2F;&#x2F;hackernoon.com&#x2F;timsort-the-fastest-sorting-algorithm-youve-never-heard-of-36b28417f399" rel="nofollow">https:&#x2F;&#x2F;hackernoon.com&#x2F;timsort-the-fastest-sorting-algorithm...</a>.<p>Unfortunately I cannot downvote.<p>Please don&#x27;t link plagiarized content. This guy also linked to his own &quot;Big O Notation&quot; in his page, where he says O(n) is polynomial<p>&gt;&gt;&gt;In our shopping list example, in the worst-case of our algorithm it prints out every item in the list sequentially. Since there are n items in the list, it takes O(n) polynomial time to complete the algorithm.
评论 #32281577 未加载
评论 #32281403 未加载
评论 #32281416 未加载
评论 #32281901 未加载
评论 #32281626 未加载
评论 #32282072 未加载