How to sort very large arrays?
dstromberglists at gmail.com
Fri Jun 13 20:24:10 CEST 2008
On Fri, 13 Jun 2008 17:54:32 +0000, kj wrote:
> I'm downloading some very large tables from a remote site. I want to
> sort these tables in a particular way before saving them to disk. In
> the past I found that the most efficient way to do this was to
> piggy-back on Unix's highly optimized sort command. So, from within a
> Perl script, I'd create a pipe handle through sort and then just print
> the data through that handle:
> open my $out, "|$sort -t '\t' -k1,1 -k2,2 -u > $out_file" or die $!;
> print $out $_ for @data;
> But that's distinctly Perlish, and I'm wondering what's the "Python Way"
> to do this.
os.system and os.popen are much like what you'd find in C.
The subprocess module is more specific to python, and is a little more
complicated but more powerful.
More information about the Python-list