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

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

Thread Previous | Thread Next
From:
ToddAndMargo
Date:
September 30, 2017 02:30
Subject:
Re: Any way to get hashes to loop in order?
Message ID:
7ee6809e-76ab-9f8a-8ebe-abbd1e075b21@zoho.com
On 09/29/2017 07:25 PM, Brandon Allbery wrote:
> On Fri, Sep 29, 2017 at 9:55 PM, ToddAndMargo <ToddAndMargo@zoho.com 
> <mailto:ToddAndMargo@zoho.com>> 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.

Poop!

Thank you for the education.

-T

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About