From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,14bff0642983a2a5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-28 09:25:28 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!yellow.newsread.com!netaxs.com!newsread.com!feed3.newsreader.com!newsreader.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!ash.uu.net!spool.news.uu.net!not-for-mail Date: Mon, 28 Jul 2003 12:25:08 -0400 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030611 Thunderbird/0.1a X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: sorting large numbers of large records References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1059409508.747658@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1059409508 2653 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:40901 Date: 2003-07-28T12:25:08-04:00 List-Id: You should read Knuth's Sorting and Searching. The classic way to do this is to read as many records from the file as you can fit in memory, sort them, and write them back out to another file. Keep doing this until you have sorted all of your original records. Now merge all the sorted subfiles together. You do that by reading a record from each subfile, writing out the smallest, and reading a new record from the file which provided the record just written.