Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://863136]
[Corion]: marto: Yeah - their mother picked all three of them up at the kindergarden to then go to the hospital, and all three of them were well behaved, and all also were quite obedient when they came home, so they recognized the situation
[Corion]: Nice to see that the kids have some understanding of important things that happen and the appropriate behaviour :)
[marto]: at times mine surprise me with this behavior :)
[Corion]: I mean, in a way it would be nicer+easier if they always where that obedient, but it's comforting to see that they are when it matters, at least for now ;)

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2016-12-08 09:28 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (138 votes). Check out past polls.