The XML::Filter::Sort module allows sorting arbitrarily large amount of data which is in XML format. You could use it like this:

  1. convert your data to XML (eg: <rec id="999999" Name="John Doe" ... /> ...)
  2. parse the XML file with a SAX parser that passes events to ...
  3. XML::Filter::Sort which sorts the events and passes them to ...
  4. XML::SAX::Writer which outputs an XML file
  5. convert the XML back to you original format

However, since XML::Filter::Sort is a SAX filter (rather than an XML filter), it's not actually necessary to use XML data at any stage of the game. Instead you could do it like this:

  1. write a simple SAX generator class (inherit from SAX::Base) which reads the text file and generates SAX events to ...
  2. XML::Filter::Sort which sorts the events and passes them to ...
  3. a simple SAX handler class which accepts events and writes out plain text in the original format

Although you didn't list maintainability as a key requirement, this type of arrangement would separate your code into logical units which each implement a well defined subset of the whole operation.


In reply to Re: Sorting A File Of Large Records by grantm
in thread Sorting A File Of Large Records 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.