Fellow Perl Monks,

I again am in need of your help again. I may not have the best approach, but I will try my best to explain what I am trying to do. I have a directory of text files with information in each of them. I did the easiest part which was to read the directory and each file for specific information and wrote it to one file for further manipulation.

Now that I have this one file I have read it into an array which I will need to now sort by the fourth subscript (array[3]) which is the date field. I know I could make it my first field, but I arranged the fields by order of importance.

I have read and even attemped a few of the examples in the previous write ups, but have had no success. I am using a tab as my delimiter which shouldn't make a difference. Here is a snippet of my code.
for (@links) { my ($status, $reference, $project, $created) = split(/\t/, $_); if ($status eq "Completed") { push(@complete, $_); } else { push(@progress, $_); } } my @sortedComplete = sort { $a->[3] <=> $b->[3] } @complete; my @sortedProgress = sort { $a->[3] <=> $b->[3] } @progress;
The four fields are defined after the declaration of my for loop. I would greatly appreciate your help. All I need is to keep all of the rows as is, but sorted by the date the project was created.

Thank you all,
Bionicle32

In reply to Sorting a slurped file by a date field by bionicle32

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.