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

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

by johnnywang (Priest)
on Dec 26, 2005 at 21:05 UTC ( [id://519204]=note: print w/replies, xml ) Need Help??


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

no modules, and no split, why? anyhow:
use strict; # use schwartzian transform if the size is big my @dates1 = ( '05-11-2006', '01-01-2005' , '04-12-2005' , '22-03-2005 +'); @dates1 = sort{substr($a,6,4)<=>substr($b,6,4)||substr($a,3,2) <=>subs +tr($b,3,2)||substr($a,0,2)<=>substr($b,0,2)}@dates1; print join("\n",@dates1); print "\n\n"; # this format is easy, it's just alpha-numeric my @dates2 = ( '2005-12-01' , '2005-11-02' , '2005-12-07'); my @dates2 = sort @dates2; print join("\n",@dates2); __OUTPUT__ 01-01-2005 22-03-2005 04-12-2005 05-11-2006 2005-11-02 2005-12-01 2005-12-07
  • Comment on Re: Sorting The Date format Values without using any perl modules.
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-19 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found