Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Sorting The Date format Values without using any perl modules.

by jkeenan1 (Deacon)
on Dec 26, 2005 at 16:23 UTC ( #519165=note: print w/ replies, xml ) Need Help??


in reply to Sorting The Date format Values without using any perl modules.

If I understand you correctly, you have a list of dates, each of which is formatted YYYY-MM-DD. Your objective is to reformat each string to DD-MM-YYYY and then to output them in date order.

The solution will probably involve sorting the YYYY-MM-DD elements alphabetically (which works out to chronologically in this case), mapping each element of the sorted list to a hash where the value is the date's index position in the sorted list. But at that point you'll have to use split to reformat the original strings before pushing them onto a new list in an order specified by the hash, which you will be using as a look-up table.

So I don't understand why you're forbidden to use split as part of the solution. Please clarify.

Jim Keenan


Comment on Re: Sorting The Date format Values without using any perl modules.
Select or Download Code
Re^2: Sorting The Date format Values without using any perl modules.
by blazar (Canon) on Dec 27, 2005 at 15:15 UTC
    But at that point you'll have to use split to reformat the original strings before pushing them onto a new list in an order specified by the hash, which you will be using as a look-up table.

    Well, split is indeed the most natural tool to do that, and the one I would use, and to stress it once more: there's really no good reason why one should not use it! (or else the OP should provide one!) But as usual TMTWOTDI: see for example the alternative I offer in this reply - it's even actually shorter...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-12-25 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls