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.


In reply to Re: sort of misunderstanding of sort by eyepopslikeamosquito
in thread sort of misunderstanding of sort by Discipulus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.