Open chuckremes opened 10 years ago
I'm a bit late to this, but better late than never XD.
Yeah. I was actually just learning about sorts and ported this from a python version I did earlier, which in turn was from a Delphi implementation. A bit hard to convert, but doable. It was more a practice in learning how the sort actually works. I never actually ran benchmarks against RBX or JRuby.
I'll look over your code in next couple of days. If you don't mind, I can use your implementation in this gem (with proper attribution of course), so that it's more available.
About a year ago I adapted some C++ smoothsort code into pure ruby as a learning exercise. I am really struck by the beauty of this algorithm even though it's quite a bit slower than merge sort, quick sort and others in practice.
I did a quick benchmark of your pure-ruby version. It's pretty pokey. From what I can tell, it's slow due to it being one single massive (and somewhat impenetrable) method. Neither JRuby nor Rubinius can inline or do any JIT optimizations on that code, so it runs slow.
If you want to see a more OOPy version of the same algorithm, check it out here: https://github.com/chuckremes/smooth-sort
I'm actually doing a quick update on it over the next few days to make it even more ruby-like so it is easy to understand from a programmer's perspective. Cheers!