What I didn't state clearly in my previous comment is this:

In the old days, Perl's sort used a QuickSort algorithm, and it was swapped out, replaced by a Merge Sort starting (if my memory serves) with Perl 5.8. This swap in the implementation of Perl's "sort" was done primarily to avoid the potential for QuickSort to go quadratic on some inputs. A secondary effect was that it provided a stable sort.

However unlikely it is that Perl would ever switch again, and this time to an unstable sort, the fact that modern Perls have a stable sort is still just an implementation detail. By specifying "use sort 'stable'", you are making a declaration of what semantics you require, leaving nothing to chance. Additionally, it signals to a future maintainer that this code would not fly if deprived of a stable sort.


Dave


In reply to Re^6: move all 0s in an array to the beginning keeping other elements order same by davido
in thread move all 0s in an array to the beginning keeping other elements order same by anilmwr

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.