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 21:02
Subject:
Re: Any way to get hashes to loop in order?
Message ID:
73882d1b-3c03-6c9f-7524-65c15d380f72@zoho.com
>> On Sep 30, 2017 12:41 PM, "Parrot Raiser" <1parrota@gmail.com 
>> <mailto:1parrota@gmail.com>> wrote:
>> 
>>     Prepending the real key value with an order indicator, then sorting
>>     the retrieved list on the key would achieve that, (though the maximum
>>     number size would have to be known in advance.
>> 
>>     E.g. 001First_key => data1, 002Second => data2
>> 

On 09/30/2017 01:59 PM, Brock Wilcox wrote:
> Maybe a list/array of pairs would be better, and then cast it to a hash 
> if you need to do fast lookups.
> 

I was going to create an "index" of the keys in an regular
array.  Then create the hash using the index.  When I
wanted to print things in order, loop on the index array,
not the hash.

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