Yes, the reason I answered your post was that I thought other monks might make the same mistake I initially made: that's why I thought it was worth showing that your solution worked for the sample data shown because of numeric coercion, and also to show the test.

This being said, and as pointed out by AnomalousMonk in Re: sorting an array with decimal points, if the OP's data is really representing version numbers (and I think that's what they are) and not decimals, then your solution would fail on, for example, 5.2, 5.14, 5.16, 5.20, because it would sort 5.2 after 5.14 and 5.16 (which would be wrong for version numbers).

But, of course, my assumptions that they are version numbers may also be wrong. Only levW can tell us what they really are.


In reply to Re^4: sorting an array with decimal points by Laurent_R
in thread sorting an array with decimal points by levW

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.