develooper Front page | perl.perl6.users | Postings from September 2017

Re: Any way to get hashes to loop in order?

Thread Previous | Thread Next
Brandon Allbery
September 30, 2017 02:25
Re: Any way to get hashes to loop in order?
Message ID:
On Fri, Sep 29, 2017 at 9:55 PM, ToddAndMargo <> wrote:

> for %SmtpIni.kv -> $key, $value { say $key; }
> Does "say" the keys in the order that I created them.
> Is there a way to get them to do so?

Not without storing that order somewhere yourself and using it to retrieve
values. The point of a hash is that it computes hash values from its keys
for fast lookup, and to the extent that any order can be said to exist for
keys in a hash, it will be related somehow to those hash values. As a
practical matter, Hashes are not considered to have any ordering.

brandon s allbery kf8nh                               sine nomine associates                        
unix, openafs, kerberos, infrastructure, xmonad

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About