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 21:02
Re: Any way to get hashes to loop in order?
Message ID:
>> On Sep 30, 2017 12:41 PM, "Parrot Raiser" < 
>> <>> 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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About