I'm reading a list of files from a folder with readdir().

I'm not in charge of the naming conventions here, I have to take what I can get.

The files are named with leading digits. The digits are good. I'd be happy to keep them in the order of the leading digits.

But my readdir() produces an array in a weird order for two files named with hypens and numbers elsewhere in the string: Here's the stretch from 50 to 60:

50doppelgangland.html
51enemies.html
52earshot.html
53choices.html
54prom.html
57freshman.html
58livingconditions.html
55grad-1.html
56grad-2.html
59theharshlightofday.html
60fearitself.html

Now I've solved my problem by doing a @listoffiles = sort {$a <=> $b} @listoffiles;, and it appears that the spaceship operator parses the files for usable numbers at the start and ignores the rest, so they come out:

50doppelgangland.html
51enemies.html
52earshot.html
53choices.html
54prom.html
55grad-1.html
56grad-2.html
57freshman.html
58livingconditions.html
59theharshlightofday.html
60fearitself.html

so, not really urgent, but what the hell was going on before? It's a LINUX server.
--

($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;

In reply to What order do my files come from readdir() in? by Cody Pendant

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.