Ok since I was away for quite some time I thought I throw in a new golf challenge... (It is an official one that is over but I still thing it is a good one):

"Human Sort"

Sort a set of lines, but with a twist.

When sorting a set of lines, humans like to see the numeric parts of a line sorted numerically and the alphabetical parts case insensitive. For the numeric parts you may ignore the possibility of negative numbers, floating point numbers and leading zeros, the numbers however are almost unconstrained in length. In other words, a sequence of one or more digits plays the same sort of role as some kind of single character, and such a sequence sorts before all normal letters, but among themselves they are ordered by numerical value. Example:

1 < A < amstelveen < Amsterdam < Amsterdam5 < Amsterdam40 < Amsterdamned

You are free in how you order e.g. fOo versus FoO or a digit versus space.

Notes:

* watch out, the original version of this question did not request case insensitivity.
* watch out, the original version of this question allowed leading zeros in the number parts, but that made programs substantially more complicated and less fun. While this change won't invalidate any existing solution, maybe you can do better now....
* The strings can also be things like: 57amstel25venn865314457646576532325988watte
* Remember, if your program is going to generate (temporary) strings of size > 2**32, it is no good. So avoid things like
"a865314457646576532325988watte" =~ /(\d+)/; 0 x $1;

OK happy golfing. I hope you like this one and YES it is something beginners to perl can try as well.

In reply to A new golf challenge - Natural Sorting by theroninwins

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.