Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Sorting Criteria

by Cine (Friar)
on Aug 05, 2003 at 18:09 UTC ( [id://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 chilling in the Monastery: (3)
As of 2024-03-29 05:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found