Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by johnnywang (Priest)
on Dec 26, 2005 at 21:05 UTC ( #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
Node Status?
node history
Node Type: note [id://519204]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-12-26 07:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (168 votes), past polls