in reply to Sorting a slurped file by a date field

It looks like you are expecting the arrays to have each element contain an array of $status,$reference,$project,$created, but you're not actually storing them that way. Try changing your pushes to be like:
push @complete, [$status, $reference, $project, $created];

Replies are listed 'Best First'.
Re: Re: Sorting a slurped file by a date field
by bionicle32 (Novice) on Feb 04, 2004 at 00:00 UTC
    I am expecting each row in the array to contain "$status\t$reference\t$project\t$created\n"

    The array has 96 rows so far and each row has four elements tab separated.

    Here I am slurping the entire file into an array.
    open (LINKS, "$linksQuery") || die ("Can't open $linksQuery: $!"); my @links = <LINKS>; close (LINKS);
    I take it one step further by separating this one array into two arrays based off of $status.
    for (@links) { chomp($_); my ($status, $reference, $project, $created) = split(/\t/, $_); if ($status eq "Completed") { push(@complete, $_); } else { push(@progress, $_); } }
    After I have these two arrays I want to sort each in most recent to latest order. I used the other response to my post, which did sort both arrays but "12/13/02 09:42:51 CST" happens to appear before 12/05/02 13:19:50 CST when it should be the other way around.

    I hope that I made things sound a little more clearier with this explanation.

    Thanks for you help again, Bionicle32
      Thanks, that's a lot clearer. To sort in descending order, simply replace $a with $b and $b with $a; e.g. in place of { $a->[3] <=> $b->[3] }, use { $b->[3] <=> $a->[3] }.

      I hope your $created's are actual numbers, not strings as you show. If you actually have strings in your data, you are going to have to parse them further, since they won't be easily comparable as is.

        They are strings like I showed in the example you responded too. Is it possible that you could further explain how I would parse them to get the dates sorted in the correct order?

        Thanks,
        Bionicle32