Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Sorting hash keys according to different criteria

by pzbagel (Chaplain)
on Jun 24, 2003 at 16:09 UTC ( #268570=note: print w/replies, xml ) Need Help??


in reply to Sorting hash keys according to different criteria

Short answer is no, long answer is maybe. No, there is no way to "order the hash". As it is written, so it shall be done. But seriously, the docs aren't lying to you, Perl stores it hashes the way it wants. No guarantee of ordering when you retrieve them.

Now I say maybe because you may feel free to write your own sorting algorithm to sort then on the fly when you want to print them out. Some clever use of the Time::localtime module to convert the month name into a number. However, since you are dealing with 12 pieces of data, that seems like overkill. Honestly, an array with the Names of the months as elements would work perfectly for your needs.

  • Comment on Re: Sorting hash keys according to different criteria

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://268570]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2022-12-05 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?