I need to be able to sort large files of the variety: Example:
18000 40000600000 1.2 2.3 2.2 5.6 7.2 20000 40000600001 2.2 3.5 3.4 5.6 3.5 15000 40000600003 2.2 3.5 3.4 5.6 3.5 20000 40000600006 2.2 3.5 3.4 5.6 3.5 20000 40000600010 2.2 3.5 3.4 5.6 3.5 20000 40000600015 2.2 3.5 3.4 5.6 3.5 20000 40000600021 2.2 3.5 3.4 5.6 3.5 20000 40000600028 2.2 3.5 3.4 5.6 3.5 20000 40000600036 2.2 3.5 3.4 5.6 3.5 20000 40000600045 1.2 2.3 2.2 5.6 7.2 19000 40000600000 1.2 2.3 2.2 5.6 7.2 19000 40000600001 1.2 2.3 2.2 5.6 7.2 19000 40000600003 1.2 2.3 2.2 5.6 7.2 19000 40000600006 1.2 2.3 2.2 5.6 7.2 20000 40000600010 2.2 3.5 3.4 5.6 3.5 19000 40000600015 2.2 3.5 3.4 5.6 3.5 20000 40000600021 2.2 3.5 3.4 5.6 3.5 19000 40000600028 2.2 3.5 3.4 5.6 3.5 20000 40000600036 2.2 3.5 3.4 5.6 3.5 19000 40000600045 2.2 3.5 3.4 5.6 3.5
The sort needs to be in ascending order based on the first 2 fields of the record. I will need to sort 100 million records. Currently, I'm using the File::Sort module and getting through about 4 million records in about 8 minutes, but its single threaded. Seems like I need to implement some sort of Merge/Sort, where I sort the smaller files and then merge. Has anybody implemented a perl solution that can handle this many records per file? I'm running on a Sun F4800, 8 CPUs, 2GB RAM - Solaris 8.

Edit: Added <code> tags around the data. larsen


In reply to Fast/Efficient Sort for Large Files by mjmaresca

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.