coldy has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I hope this is not too trivial. I have a hash that is filled and then passed into another function. The problem is this function needs the order of the hash keys in a specific way. Anybody know how to do this
eg My hash gets filled so it looks likebut needs to be in this order for use in a function%my_hash =('cat' =>,7, 'dog'=>3, 'cow'=>9,)
basically I need to sort the hash by the specific order of this array%my_hash = ('dog' => 3, 'cat' => 7, 'cow' => 9,)
then I can use tie:IxHash to preserve the order@array= ("dog","cat","cow")
Many thanks for any help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash ordered by an array
by BrowserUk (Patriarch) on Jul 11, 2008 at 09:56 UTC | |
by baxy77bax (Deacon) on Jul 11, 2008 at 12:42 UTC | |
|
Re: hash ordered by an array
by Anonymous Monk on Jul 11, 2008 at 07:04 UTC | |
|
Re: hash ordered by an array
by Narveson (Chaplain) on Jul 11, 2008 at 17:11 UTC | |
by coldy (Scribe) on Jul 13, 2008 at 11:18 UTC |