in reply to sort of misunderstanding of sort
My recent experiences during Rosetta Code: Long List is Long taught me that vanilla sorting in Perl tends to be slow.
Even Perl experts were surprised. I was similarly shocked when changing from one sort to two (sort { $href->{$b} <=> $href->{$a} || $a cmp $b } keys %{$href} to sort { $href->{$b} <=> $href->{$a} } sort keys %{$href}) gave a massive performance boost ... and nearly fell off my chair when I later accidentally out-mario-royed marioroy via GRT. :)
I also learnt that stable sorting algorithms tend to run significantly slower than unstable ones in practice. Yet I don't see Perl supporting unstable sorting algorithms in the near future given:
From sort - perl pragma to control sort() behaviour "The sort pragma is now a no-op, and its use is discouraged ... The default sort has been stable since v5.8.0, and given this consistent behaviour for almost two decades, everyone has come to assume stability"
The other huge sorting performance boost (pun intended) I remember was here when Boost's sort::block_indirect_sort parallel sort algorithm, running on 8 threads simultaneously, ran massively faster than single-threaded vanilla C++ std::sort.
I would be interested to learn of future plans to improve Perl sorting performance.
See also my mandatory list of Sorting References.
|
|---|