Subj : Re: Sorting To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Tue Dec 09 2003 09:41 am Nokomis wrote: >Anyone know an algorithm for sorting large numbers of character strings? > >Something like a telephone direcctory - too big for a normal array. Data resides in a file? Is this fixed-length records or variable? You know Bubble Sort, right? Use Bubble Sort algorythm for the outside block, and the fastest sort you care to use for the inner block. Array[2000] RecordPointer A=0,B; while( A < FileRecords-1000 ) { read 1000 records from A into Array[0] B = A+1000 if( B >= FileRecords ) fastsort 2000 records /* small file */ while( B < FileRecords ) { read 1000 records from B into Array[1000] fastsort 2000 records write 1000 records to B from Array[1000] B+=1000 } write 1000 records to A from Array[0] A += 1000 } Adjust "1000" to suit your memory/speed requirements. Since this is an "in-place" sort, it would be safer to copy the file, sort the copy, then rename upon completion. That way a power outage or other mishap won't leave you with scrambled data. .