Bukowski has asked for the wisdom of the Perl Monks concerning the following question:
I have a hash, with keys being month names and values being number of days in the month.
If I want to print the keys out in a *non-alphabetical* order (if I sort them then I get "April", "August", "December", "February" etc.) particularly the order in which they come in - (Jan to Dec) how can I do this? Or am I going to end up with another hash holding the month, and an integer representation to refer to in the sort?
I know hash entries are effectively random when set up based on memory location, but there must be some trick to ordering the hash keys as I wish.. I had a look at Date::* but nothing lept out at me
Many thanks
Bukowski - aka Dan (dcs@black.hole-in-the.net)
"Coffee for the mind, Pizza for the body, Sushi for the soul"
-Userfriendly
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Sorting hash keys according to different criteria
by merlyn (Sage) on Jun 24, 2003 at 15:58 UTC | |
by Bukowski (Deacon) on Jun 24, 2003 at 16:01 UTC | |
Re: Sorting hash keys according to different criteria
by Bilbo (Pilgrim) on Jun 24, 2003 at 15:57 UTC | |
Re: Sorting hash keys according to different criteria
by George_Sherston (Vicar) on Jun 24, 2003 at 17:19 UTC | |
by Anonymous Monk on Jun 24, 2003 at 20:57 UTC | |
by George_Sherston (Vicar) on Jun 24, 2003 at 21:46 UTC | |
Re: Sorting hash keys according to different criteria
by pzbagel (Chaplain) on Jun 24, 2003 at 16:09 UTC |