in reply to Re^2: sort based on date
in thread sort based on date

Unless you know all the dates in the set are from the same year.
Sure, but no such assumption was stated by the OP. An equally valid assumption would be "next occurrence" of the given dates - one might for instance have to order dates for soccer matches of the coming season.

My meta point of course is that if people post problems here, they shouldn't hide essential knowledge about the problem (I do assume the OP knows which years the dates are supposed to have).

Replies are listed 'Best First'.
Re^4: sort based on date
by BrowserUk (Patriarch) on Aug 09, 2010 at 15:13 UTC
    Sure, but no such assumption was stated by the OP.

    Perhaps he thought, given the absence of year information in the sample data, the assumption was too obvious to state.

    (I do assume the OP knows which years the dates are supposed to have).

    I assume OPs to know their problem space. They sometimes prove me wrong, but the alternative of every SoPWer being required to fully delineate every possible constraint and nuance of their problems, would severely detract from concise and lucid questions.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^4: sort based on date
by suhailck (Friar) on Aug 09, 2010 at 11:25 UTC
    JavaFan, you are right.

    My date contains only one year.
    It wont include Aug 2009 and Aug 2010 at the same time.
    The script search through a log file for last 6 months period.


    ~suhail
      Your example contains a January date, which is more than 6 month ago.

      Note also that for half a year, the previous 6 months will contain dates from more than one year. I presume that if you're running your program in March, you'd want December dates to be sorted before January dates, don't you?

        Right, my example is just a sample code written to demonstrate my requirement.
        I didnt notice January included in that array :(
        And let me clarify my requirement, im looking for a minimal approach of reading my firewall log and make a report with DoS attacker's IP,Threat type, No. of attempts, and Last attempt date.
        I need this report only twice a year.That is, from Jan 2010 - June 2010, Jul 2010 - Dec 2010, Jan 2011 - Jun 2011 so on ..
        I would like to archive my log file after each period.
        So i hope this approach will help me in acheiving my task.


        Thanks very much for your support :)

        ~suhail