On Jun 14, 1:54 am, kj <[EMAIL PROTECTED]> 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
On Jun 14, 1:54 am, kj <[EMAIL PROTECTED]> 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
import collections
names = "freddy fred bill jock kevin andrew kevin kevin jock"
freq = collections.defaultdict(int)
for name in names.split():
freq[name] += 1
keys = freq.keys()
keys.sort(key = freq.get, reverse = True)
for k in keys:
print "%-10s: %d" % (k, freq[k])
On Jan 9, 6:58 p