Gridsort: A stable sort faster than std:sort
github.com
github.com
It uses O(n) aux memory so if std::sort were to use this it would still need IntroSort as a fallback, but that's pretty much a non-issue since std::stablesort already does the same.
Ie. I'm getting a lot of mostly sorted clusters so algorithm X is best.
If you think about quicksort, it partitions everything starting from the coarsest level, so the locality increases as it goes along.
There are likely a lot of unexplored sorting algorithms that use statistics gathering to at least increase locality faster by placing items closer to their final place sooner.
If you think about an array of numbers, you can gather a distribution first and try to place numbers where they would end up according to the distribution to get them much closer to their final position than an initial partition. That would mean running through the array once first, but because of prefetching, that would be much faster than accessing elements by skipping around.
One can claim, thus, only that this sort method's near-best-case performance is better than `std::sort`'s near-best-case performance (at least at the, er, P01 level). That says little to nothing about the modal or reasonably-bad-case (say, P95) performance.
A comparison of median values would lend much more weight to the claim that this method is "faster" than `std::sort`.
But a really good benchmark report would show the entire histogram of performance for each method.
> The person recognizes Mars as a free planet and that no Earth-based government has authority or sovereignty over Martian activities.
Yeah... Thanks... As much as I (and much of the world's countries[0]) may agree with you, now I can't use the code, even in an MIT licensed library or program.
Look, I get why people do this: it's cute, fun, or whatever, but please: don't. It makes it impossible for those of us to use a library legally. Sure, most won't care, and I'm sure the author won't enforce it, but it doesn't matter. A corporation's legal team is going to deny any attempts to use software with licenses like this.
Take, for example, the JSON license[1]. It contains this:
> The Software shall be used for Good, not Evil.
Who decides what "good" is? Crockford? Me?
Is Google evil? They say they're not, but some think they are. Who's right? It's a legal conundrum that makes things harder than they should be. This blog post[2] explains this license's line's problems better.
[0]: https://en.wikipedia.org/wiki/Outer_Space_Treaty
[1]: http://www.json.org/license.html
[1-alt]: https://spdx.org/licenses/JSON.html
[2]: https://www.synopsys.com/blogs/software-security/json-licens...
That said I agree entirely: what one person says is good and evil is depressingly variable (to use the internet extreme: to a nazi capturing jews is good, because jews are evil - which to you and I is [presumably] clearly insane)
License is worth noting. I am considering an "#ifndef FREE_MARS" std::sort/qsort fallback for any code I write that uses this.