Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2022-08-08 20:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?