in reply to Sorting Times

Depending on your situation it might be a good idea to rethink your data. Personally, I'm a big fan of doing date/time calculations using # of seconds since the epoch (that is, on Unix, time and date are described as the number of seconds since January 1, 1970.) Number of seconds is a very handy format: it's easy to sort, easy to manipulate (need to add or subtract a minute/hour/day/month? Piece of cake!) and easily transferable back and forth into something legible using localtime() and Time::Local.

Of course, you might not have that option... but IMHO dealing in epoch-time is a good habit to get into.

Gary Blackburn
Trained Killer

Replies are listed 'Best First'.
Re: Re: Sorting Times
by Rhandom (Curate) on Apr 28, 2001 at 12:10 UTC
    it's easy to sort

    Beware the ides of September.
    <code> perl -e 'print time."\n".localtime(1_000_000_000)."\n";'

    my @a=qw(random brilliant braindead); print $a[rand(@a)];
      Says Rhandom:
      Beware the ides of September.
      perl -e 'print time."\n".localtime(1_000_000_000)."\n";'
      Nice thought, but the ides of September don't begin until 1_000_339_200. (Plus or minus a bit, depending on time zones and local conventions.)

      --
      Mark Dominus
      Perl Paraphernalia