the hash must traverse the internal data structures in some order to produce the list, but that sequence is explicitly undefined. That is the essence of being unordered.

I've been watching from the sidelines and for the most part, this seems like a prime example of what killed the Pedants' Conference--they died arguing about whether the ' should be before or after the s--but I've always enjoyed a good freindly debate, so here goes nothing :)

I would say that for all hash implementations, including Perl's current, (and all previous) implementations, they do have an "intrisic ordering". That ordering is a definable and concrete function of 2 factors:

And given knowledge of algorithm (use the source), and the current bucket size, (see the second element of scalar %hash), the ordering is knowable; therefore definable; therefore defined by the implementation(s).

However, I agree with the earlier statement--I've lost track of who made it (first)--that there is a significant difference between "order(|ing|ed)" and "sort(|ing|ed)".

And the answer to the OP question is:

Whilst the iteration order of arrays is, (for most (all?) languages), unspecified, it is defined, (by convention), to be the same as the natural ordering of its integer indexes; whereas, the iteration order of hashes, (also unspecified), is defined, (as a matter of practicality), to be the simplest or most efficient, (which are often the same thing), order of traversal of the data-structures underlying the implementation.

As hash implementations differ, the ordering differs with implementation; whereas the natural ordering of integer indexes does not.

QED.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^10: What makes an array sorted and a hash unsorted? by BrowserUk
in thread What makes an array sorted and a hash unsorted? by ikegami

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.