pauld wrote:
Gunnar Hjalmarsson wrote:
pauld wrote:
im using Date::Manip to convert dates  and times eg  2007:08:02 12:23
to allow me to sort them,

Why are you doing that?

C:\home>type test.pl
@dates = ( '2007:08:02 12:23', '2007:10:21 04:40',
              '2007:06:05 16:08', '2007:09:11 22:20', );
print "$_\n" for sort @dates;

C:\home>test.pl
2007:06:05 16:08
2007:08:02 12:23
2007:09:11 22:20
2007:10:21 04:40

im sorting it on a key of the hash
my @daylistsorted = sort { $$a{'START_DS'} <=> $$b{'START_DS'} }
@daylist;
 generates a
Argument "2007:09:30 13:41" isn't numeric in numeric comparison (<=>)
at ./518573

My point is that the format "yyyy:mm:dd hh:mm" is sortable without conversion. However, you need to sort lexically, i.e. use the cmp operator instead of the <=> operator.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to