News for hackers. Stuff that matters.
Re:Timsort is a sorting algorithm that is efficient for real... by bbno4 on Sunday July 01, 2018 @04:16PM (#17437334)
Hey! Author here! Thank you so much for posting this here! If you have any questions feel free to ask me
Re:Timsort is a sorting algorithm that is efficient for real... by aidenn0 on Sunday July 01, 2018 @05:39PM (#17437770)
It was not apparent from your article how Timsort ensures stability. After doing some reading on my own I was able to discover that it is done so by only reversing strictly decreasing runs, and by never reordering runs.

While your description covers both of those points[1], it didn't mention them together as contributing to stability.

1: Actually rereading to make sure I didn't miss anything, you have a mistake, as you say: "Runs have to be strictly increasing or decreasing" while they have to be either monotonically increasing (i.e. non-decreasing) or strictly decreasing.

so: 1,2,2,3 is a run, but 3,2,2,1 is not.

Re:Timsort is a sorting algorithm that is efficient for real... by enriquto on Monday July 02, 2018 @03:34AM (#17439883)
The exposition of the sorting algorithm is beautiful and clear. Thanks!

Your disparaging of academic work is utterly ridiculous. I am a mathematician working in academia with real world data, developing algorithms that are used in industry. This sentence at the begining of your article makes me think that you are not really aware of how the real world works.

Re:Timsort is a sorting algorithm that is efficient for real... by quickben on Sunday July 01, 2018 @10:44PM (#17438999)
Sure. Why are you highlighting this wasn't "created in an academic laboratory". Do you think your blogging approach of thinly veiled negativity toward established peer-reviewed works will give you more likeability among the general readership?
Re:Timsort is a sorting algorithm that is efficient for real... by alexbecker on Sunday July 01, 2018 @04:53PM (#17437500)
Is the implementation at the end of the article complete? I don't see anything that looks like the "galloping" behavior described just prior.
Re:Timsort is a sorting algorithm that is efficient for real... by bbno4 on Sunday July 01, 2018 @05:42PM (#17437784)
Ooh, it's actually not complete. I put that as a placement while I tried to find the original source code for it. I didn't expect it to be shared anywhere. me. Thank you for bring this to my attention, I'll see if I can find the source code again, terribly sorry for doing the worst thing imaginable and publishing something that isn't complete!
Re:Timsort is a sorting algorithm that is efficient for real... by kbd on Sunday July 01, 2018 @04:24PM (#17437369)
> Since the algorithm has been invented it has been used as the default sorting algorithm in Python, Java, the Android Platform, and in versions of GNU.

I'm glad you mentioned how far the algorithm has spread to other languages since originating in Python. But, "versions of GNU" what?

Re:Timsort is a sorting algorithm that is efficient for real... by LeoPanthera on Sunday July 01, 2018 @04:48PM (#17437473)
I assume he means sort/gsort, from the coreutils.
Re:Timsort is a sorting algorithm that is efficient for real... by eesmith on Sunday July 01, 2018 @05:36PM (#17437758)
http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/sort... says:

   Use a recursive divide-and-conquer algorithm, in the style
   suggested by Knuth volume 3 (2nd edition), exercise 5.2.4-23.  Use
   the optimization suggested by exercise 5.2.4-10; this requires room
   for only 1.5*N lines, rather than the usual 2*N lines.  Knuth
   writes that this memory optimization was originally published by
   D. A. Bell, Comp J. 1 (1958), 75.
Re:Timsort is a sorting algorithm that is efficient for real... by seba_dos1 on Sunday July 01, 2018 @04:53PM (#17437503)
Versions of GNU. Although it's rare to see this term being used in this context these days, "GNU" was invented as a name of an operating system.
Re:Timsort is a sorting algorithm that is efficient for real... by eesmith on Sunday July 01, 2018 @05:54PM (#17437842)
Where is TimSort used in a GNU operating system?

I suspect this line originates from the Wikipedia entry for TimSort with the line:

"Timsort has been Python's standard sorting algorithm since version 2.3. It is also used to sort arrays of non-primitive type in Java SE 7,[3] on the Android platform,[4] and in GNU Octave."

Notice how the order of Python, Java, Android, and GNU is the same? My tentative hypothesis is that "Octave" was dropped, and that "GNU" here means something more like "in the GNU project."

Also, the author uses a time complexity table with Ω(), Θ(), and O() notations, but suggests "To learn about Big O notation", go to another hackernoon article which only talks about O() and not big omega or big theta notations.

Re:Timsort is a sorting algorithm that is efficient for real... by copperx on Sunday July 01, 2018 @05:36PM (#17437757)
That raises the question, what does the Hurd kernel use timsort for?
Re:Timsort is a sorting algorithm that is efficient for real... by Anm on Sunday July 01, 2018 @04:25PM (#17437375)
In your example of reversing decreasing runs, you dropped a 9.
Re:Timsort is a sorting algorithm that is efficient for real... by bbno4 on Sunday July 01, 2018 @05:37PM (#17437762)
Thank you so much!
Re:Timsort is a sorting algorithm that is efficient for real... by czr on Sunday July 01, 2018 @06:45PM (#17438111)
another minor typo:

> do the merging as soon as possible to exploit the run that the run just found is still high in the memory hierarchy

s/run/fact/ if I'm reading correctly

for the python timsort, the original source code is here: https://svn.python.org/projects/python/trunk/Objects/listobj..., although porting it to idiomatic python definitely seems nontrivial

Re:Timsort is a sorting algorithm that is efficient for real... by czr on Saturday July 07, 2018 @11:50AM (#17479011)
Also, it looks like the pypy implementation is here: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/lis...
Re:Timsort is a sorting algorithm that is efficient for real... by jwilk on Monday July 02, 2018 @12:10PM (#17442870)
Re:Timsort is a sorting algorithm that is efficient for real... by czr on Saturday July 07, 2018 @11:47AM (#17479000)
Oops, thanks! That's much better. Not sure why I stumbled on the svn link first.