Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: sorting a file by a date:"YYYY-MM-DD" field with cmp

by davido (Cardinal)
on Jun 16, 2015 at 17:44 UTC ( #1130652=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub sortByDate
    {
    ...
    
        return ($aDate cmp $bDate);
    }
    
  2. or download this
     
        my($aDate) = $a =~ /date\"(\d{4}-\d{2}-\d{2})"/;
        my($bDate) = $b =~ /date\"(\d{4}-\d{2}-\d{2})"/;
    
  3. or download this
    use strict;
    use warnings;
    ...
    { "date":"2015-01-02", "content":"erts" }
    
    { "date":"2014-04-02", "content":"w34r" }
    
  4. or download this
    Unsorted:
    [
    ...
      { content => "asdf", date => "2015-03-01" },
      { content => "erwa", date => "2015-05-01" },
    ]
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2022-05-25 01:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (84 votes). Check out past polls.

    Notices?