I suggest you try using a relational database to do the job for you. I'm not claiming that this will work for datasets as large as yours, but give it a try.

MySQL sample code:
CREATE DATABASE sorter; USE sorter; CREATE TABLE t619575 ( c01 varchar(2), -- SK c02 integer, -- 1242 c03 integer, -- 0180010100 c04 varchar(3), -- AAR c05 varchar(3), -- CPH c06 varchar(3), -- AAR c07 integer, -- 0735 c08 varchar(3), -- CPH c09 integer, -- 0810001 c10 bigint(25), -- 20070521200705211 c11 varchar(2), -- SK c12 integer -- 1242 ); -- Assuming tab separated columns LOAD DATA LOCAL INFILE '619575.csv' INTO TABLE t619575 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\'; -- Add index on the fields to sort ALTER TABLE t619575 ADD INDEX idx_c02_c03_c04 (c02, c03, c04); -- Create sorted output SELECT * INTO OUTFILE '619575.sorted.csv' FROM t619575 ORDER BY c02, c03, c04 ;
Some may claim that MySQL isn't up for this kind of job. If it doesn't, then you might consider downloading the free (as in gratis) versions of Oracle or DB2.
--
print map{chr}unpack(q{A3}x24,q{074117115116032097110111116104101114032080101114108032104097099107101114})

In reply to Re: Sort large files by andreas1234567
in thread Sort large files by ramish

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.