Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Sorting Criteria

by Cine (Friar)
on Aug 05, 2003 at 18:09 UTC ( #281111=note: print w/replies, xml ) Need Help??


in reply to Sorting Criteria

Aristotle already told what was wrong, so here is a suggestion for your sort method:
sub sorter { "$hashYear{$a}$hashMonth{$a}$hashDay{$a}" <=> "$hashYear{$b}$hashMon +th{$b}$hashDay{$b}" }


T I M T O W T D I

Replies are listed 'Best First'.
Re: Re: Sorting Criteria
by sgifford (Prior) on Aug 05, 2003 at 18:48 UTC
    That will work if days and months are zero-padded. Otherwise, "1/11" will compare equal to "11/1".
      Yeah, silly me
      sub sorter { sprintf"%04d%02d%02d",$hashYear{$a},$hashMonth{$a},$hashDay{$a} <=> sprintf"%04d%02d%02d",$hashYear{$b},$hashMonth{$b},$hashDay{$b} }


      T I M T O W T D I

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2023-12-03 01:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (20 votes). Check out past polls.

    Notices?