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

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

Thread Previous | Thread Next
September 30, 2017 02:30
Re: Any way to get hashes to loop in order?
Message ID:
On 09/29/2017 07:25 PM, Brandon Allbery wrote:
> 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.


Thank you for the education.


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