Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Need help comparing 4 dates

by ig (Vicar)
on Oct 03, 2010 at 04:22 UTC ( #863136=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Need help comparing 4 dates
in thread Need help comparing 4 dates

Given a list of dates, to calculate a corresponding list of ordinals I might do something like the following:

# Make a list of tuples: (index, date) my @list = map { [ $_, $dates[$_] ] } (0..$#dates); # Sort the list by date @list = sort { Date_Cmp($a->[1], $b->[1]) } @list; # Determine the corresponding ordinal numbers my @ordinals; foreach (0..$#dates) { $ordinals[ $list[$_]->[0] ] = $_ + 1; }

I don't find this very elegant - there may be much better ways. There may be a module that does this, though I don't know one.


Comment on Re^3: Need help comparing 4 dates
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2014-09-02 00:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (18 votes), past polls