Sorting large files

Charles G Waldman cgw at fnal.gov
Wed Dec 22 14:02:50 EST 1999


Edward C. Jones writes:
 > A Python program of mine generates a large number of tuples of
 > ten integers each. I need to sort this collection of tuples. If
 > there weren't so many tuples, I could make a Python list of these
 > tuples and use sort(). Currently I write the tuples out to a file
 > in ASCII and use the UNIX sort command. Is there a faster way to
 > sort these tuples? Sort them in blocks using Python then merge
 > using the UNIX sort? Are there any faster sort programs (perhaps
 > in database systems)?

The list.sort method in Python uses quicksort (AFAIR) so it's just as
efficient as using UNIX sort.  What's your reason for not just doing
exactly what you suggest, making a big Python list and sorting it?
Total memory consumption?





More information about the Python-list mailing list