Once in a while, I found a funny and interesting thing related to coding. I love coding (and to code). So, when somebody forwarded this - Stalin Sort, I laughed so hard but at the same time was intrigue. (Here is the link: https://github.com/gustavo-depaula/stalin-sort)
The main gist of this "Stalin Sort" is that if you found an element that does not met with the sort criteria, you send it "to Gulag". Ha ha ha. That is so funny. You just delete or drop the element. Just like what Stalin would do.
Later, I checked the github codes. Lots of codes there. The first thing I do is to find Perl implementation. I love perl. There, I found exactly what I wanted to see, a beautiful implementation. No, not the one-liner but the more verbose one. I love to explain things. When I see code that "no need to explain", you know you find a good code. It's just like jokes. If you have to explain it, it's not a good joke.
Few days ago, I just had to roll my own Python implementation. It was midnight. I was worried that it could take me quite a while to code it, but it just took me a few minutes. So here it is. (It is also available in here: https://pastebin.com/Vk3NwcYG)
Comments