in reply to In-place sort with order assignment
Could I perchance repeat my suggestion of, “do it the COBOL way?”
External disk-based sorting ... easily done in Perl ... can accommodate millions of records, and runs with counter-intuitive speed. When this is done, to any data set, you know two things:
Therefore, work with a sorted file, then also sort your input file(s) in the same sequence. Having done so, you can now process the two files together, sequentially, without “searching.”
In the early days of movies, anytime Hollywood wanted to film a real digital computer, the operators would start a tape-sort. All those spinning tapes made wonderful footage. You may or may not have noticed that they never slowed down or ran backwards. They processed very large amounts of data, very efficiently, doing so without large amounts of RAM or random-access storage, neither one of which was available at the time. You can expect “more than hundred-fold increases” in efficiency for many algorithms ... including the time spent doing the sorts, which is “far less time than you think.”
Never forget that “memory is a disk-file, too.”
“Don’t diddle the code to make it faster: choose a better algorithm.”
-- Kernighan & Plaugher; The Elements of Programming Style.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: In-place sort with order assignment
by BrowserUk (Patriarch) on Sep 21, 2010 at 15:07 UTC | |
by Limbic~Region (Chancellor) on Sep 21, 2010 at 15:37 UTC | |
by BrowserUk (Patriarch) on Sep 21, 2010 at 15:59 UTC |