Board index » delphi » how do i sort records in files
Diabolic_Preacher
![]() Delphi Developer |
Tue, 06 Jul 2004 21:18:58 GMT
|
Diabolic_Preacher
![]() Delphi Developer |
Tue, 06 Jul 2004 21:18:58 GMT
how do i sort records in files
just the idea i'll learn myself the technical side of it
-- --- |
Markus Hum
![]() Delphi Developer |
Wed, 07 Jul 2004 00:01:31 GMT
Re:how do i sort records in filesQuoteDiabolic_Preacher wrote: or linked list) and sort this. Rewrite the whole file afterwards with the sorted entries. Other thing: use a temporary file to build the sorted one. Read through the data file and get the next needed value. Write it to the temp file. Afterwards the temp file will be sorted and the data file may be erased and the tempfile may be renamed to the name of the data file. Btw: there might be other/better solutions! Greetings Markus |
Bob Scho
![]() Delphi Developer |
Wed, 07 Jul 2004 03:10:20 GMT
Re:how do i sort records in filesFor really large files where it does NOT all fit into memory at once, there's something called Polyphase Sort, originally developed back when "mass storage" meant a tape drive, memory size was measured in K (not M), and Machines were really Machines (meaning you couldn't pick one up). The basic idea is as follows: Assume you have N+1 "tapes", with the That's the "initialization step". Now proceed to merge the N tapes back Now you can start the final repetetive phase. Distribute the existing I think if you find a description of Polyphase Sort, it might differ Bob Schor QuoteDiabolic_Preacher wrote: |
Christopher Secor
![]() Delphi Developer |
Sun, 11 Jul 2004 04:34:44 GMT
Re:how do i sort records in filesIf the data is sufficiently unbiased, it is also possible to make one pass through the file to read all the A's. Sort these and write them to output. Then make another pass for the B's etc. Of course, if you have the memory you can read all the A's, B's and C's, and As I mentioned this only really works for unbiased data - that is, data with Quote"Diabolic_Preacher" <pintoo...@remyahoo.com> wrote in message Quote> just the idea i'll learn myself the technical side of it |