I have to write a script that can take a file that is in the format:
TRU-01(A),07Jul2008 03:00:01,ECG X/X,SAO2 X/X,NBP 115/59 77 02:41,CO2 +X/X/X,ST X/X/X,ST X/X/X,ST X/X/X,ST X/X/X
Most of the time, the file is missing certain statistics, such as SAO2, RESP, etc.

I need to be able to create a standardized formatting each time, so the log file will always have name1 data1, name 2 data2, etc.

However, the problem is that the data is often arranged differently, so NBP and its data might come before ECG and its data.

I think the easiest way would simply be to read the file for all the different names, sort those alphabetically, and use that to create a standard order for the data to appear in.

If anyone could suggest a way to do that, i would greatly appreciate it.


In reply to Sort log file alphabetically by Anonymous Monk

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.