[Tutor] Sorting large numbers of co-ordinate pairs
Alan Gauld
alan.gauld at btinternet.com
Thu Mar 12 18:50:21 CET 2009
"Dinesh B Vadhia" <dineshbvadhia at hotmail.com> wrote
> Have a large number (> 1bn) of integer co-ordinates (i, j).
> I want to create (j, i) with j ordered and i unordered ie.
> I've tried the dictionary route and it works perfectly for small set
> of
> co-ordinate pairs but not for large sets as it hits memory capacity.
One option is to load them into a database and use its sort
facilities.
Another is to use the old mainframe approach of batching
the data and sorting each batch. Its then a relatively easy job
to merge the sorted batches back into a single file without
ever holding the whole thing in memory at once. But its not fast...
HTH,
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list