in reply to compare dates?

ha
use strict; use warnings; my @d = qw[ 06/30/96 08/07/97 09/05/97 12/11/97 03/26/98 07/17/98 10/23/98 11/12/98 01/14/99 04/10/99 05/27/99 02/10/00 03/10/00 03/15/00 03/15/00 03/30/00 06/15/00 07/13/00 08/03/00 09/07/00 09/30/00 12/10/00 01/25/01 02/27/01 ]; print $$_[0], $/ for sort { my @f = $$a[1] <=> $$b[1]; push @f, $$a[2] + <=> $$b[2]; push @f, $$a[3] <=> $$b[3]; return $f[0] if $f[0] != 0; +return $f[1] if $f[1] != 0; return $f[2]; } map { /(\d+)\D(\d+)\D(\d+ +)/; [$_, $3,$2,$1] } @d; __END__ 08/03/00 09/07/00 02/10/00 03/10/00 12/10/00 07/13/00 03/15/00 03/15/00 06/15/00 03/30/00 09/30/00 01/25/01 02/27/01 06/30/96 09/05/97 08/07/97 12/11/97 11/12/98 07/17/98 10/23/98 03/26/98 04/10/99 01/14/99 05/27/99

Replies are listed 'Best First'.
Re^2: compare dates?
by CountZero (Bishop) on Apr 09, 2008 at 18:24 UTC
    The Y2K bug has bitten you!

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      Ha, thats what you think :) To me 00 means 1900, and 99 means 1999
        The OP said that the list was already sorted, so "00" must come by definition after "99".

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re^2: compare dates?
by starbolin (Hermit) on Apr 09, 2008 at 18:02 UTC

    Some Anonymous Monk writes:

    print $$_[0], $/ for sort { my @f = $$a[1] <=> $$b[1]; push @f, $$a[2] <=> $$b[2]; push @f, $$a[3] <=> $$b[3]; return $f[0] if $f[0] != 0; return $f[1] if $f[1] != 0; return $f[2]; } map { /(\d+)\D(\d+)\D(\d+)/; [$_, $3,$2,$1] } @d;

    Are you sure you didn't mean to post this in Obfuscated code?


    s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}
      Why? Theres nothing obfuscated about it.