https://docs.python.org/2/howto/sorting.html#sort-stability-...
https://stackoverflow.com/questions/10948920/what-algorithm-...
21–30 of 135 posts
https://docs.python.org/2/howto/sorting.html#sort-stability-...
https://stackoverflow.com/questions/10948920/what-algorithm-...
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.
Edit: Whoops, apparently heapsort is not "stable" (not sure what that means actually), sorry.
Earlier quoted context omitted.
Note that this is true for any (edit: stable, nlogn) merge sort.
Heapsort is a lovely, simple, O(NlogN) sort that sorts in place (so that it requires no extra space). (Explicitly stating something that is implied by an existing response). Edit: Whoops, apparently heapsort is not "stable" (not sure what that means actually), sorry.
The first software patent, for SyncSort, is for a sort that beats O(n log n). The basic idea is to read records for a while, get some stats about the key distribution, and set up the buckets to get a roughly equal fraction of the observed keyspace. If blocks of records show up with very different stats, action has to be taken to adjust the bucketing.
My favourite TimSort story is of ex-Sun employee, Joshua Bloch of Effective Java fame. J Bloch was in audience at the time when Tim Peters presented his new algorithm to sort a list, and he was so blown away that he started porting Tim's implementation right there with an intent to commit it to the JDK mainline [0], which he eventually did [1]. [0] Some of the core JDK developers are really on another level. The JDK…
https://link.springer.com/chapter/10.1007/978-3-319-21690-4_...
Earlier quoted context omitted.
you can do merge sort in place
You can’t. Merge sort copies data back and forth between two spaces the size of the data set. That’s O(n) extra space. I spent some time four summers ago with merge sort. I had a PoC for an in-place algorithm that survived several rounds of poorly selected sample data. That was quite a disappointment. In looking around I believe I ran across several implementations that required sqrt(n) extra space and one that I thi…
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.22....
[1] https://docs.python.org/3/howto/sorting.html#sort-stability-...
[2] https://docs.python.org/3/library/stdtypes.html#list.sort
My favourite TimSort story is of ex-Sun employee, Joshua Bloch of Effective Java fame. J Bloch was in audience at the time when Tim Peters presented his new algorithm to sort a list, and he was so blown away that he started porting Tim's implementation right there with an intent to commit it to the JDK mainline [0], which he eventually did [1]. [0] Some of the core JDK developers are really on another level. The JDK…
[0] https://dertompson.com/2012/11/23/sort-algorithm-changes-in-...
"never heard of"?? I would hope all Python devs at some point Google "What algorithm is Python's built-in sort function?"... https://docs.python.org/2/howto/sorting.html#sort-stability-... https://stackoverflow.com/questions/10948920/what-algorithm-...
This article is based on Tim Peters’ original introduction to Timsort, found here.