in reply to The strange ordering of hash values

This happens because you are storing your values in a hash, and sorted position is not maintained in a hash. If you want to maintain the ordering, use an array instead.

BTW, hashes are usually populated in this manner:

%hash = ("one" => 1 , "Two" => 2, "three" => 3, "four" => 4);

Where do you want *them* to go today?
  • Comment on Re: The strange ordering of hash values

Replies are listed 'Best First'.
Even better
by Jedaļ (Initiate) on Apr 19, 2007 at 21:13 UTC

    Actually, you would rather write this as :

    %hash = (one => 1 , two => 2, three => 3, four => 4);

    since one of the nice point of "=>" is that it allows to use a bareword on it's left side without strict protesting about it (well it's obvious here that you want a string on this side so it's nice not having to be explicit about it in my opinion, => is a nice syntaxic sugared comma).

    --
    Jedaļ
    A reply falls below the community's threshold of quality. You may see it by logging in.