Popular recipes tagged "file", "text" and "sorting"http://code.activestate.com/recipes/tags/file+text+sorting/2009-05-30T21:51:09-07:00ActiveState Code RecipesSorting big files the Python 2.6 way (Python)
2009-05-30T21:51:09-07:00Gabriel Genellinahttp://code.activestate.com/recipes/users/924636/http://code.activestate.com/recipes/576755-sorting-big-files-the-python-26-way/
<p style="color: grey">
Python
recipe 576755
by <a href="/recipes/users/924636/">Gabriel Genellina</a>
(<a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/sort/">sort</a>, <a href="/recipes/tags/sorting/">sorting</a>, <a href="/recipes/tags/text/">text</a>).
Revision 3.
</p>
<p>This is just a rewrite of <a href="http://code.activestate.com/recipes/466302/">Recipe 466302</a> "Sorting big files the Python 2.4 way", taking advantage of heapq.merge, context managers, and other niceties of newer Python versions. It can be used to sort very large files (millions of records) in Python. No record termination character is required, hence a record may contain embedded binary data, newlines, etc. You can specify how many temporary files to use and where they are located.</p>