space-efficient top-N algorithm
John Machin
sjmachin at lexicon.net
Mon Feb 10 06:22:04 EST 2003
More information about the Python-list mailing list
Mon Feb 10 06:22:04 EST 2003
- Previous message (by thread): space-efficient top-N algorithm
- Next message (by thread): space-efficient top-N algorithm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
b_mcerlean at yahoo.com (Brian McErlean) wrote in message news:<f040c4f9.0302092300.79757ffd at posting.google.com>... > I take it by the references to sorting and descending order that you're > getting the top 50 elements by sorting the dict? ie. something like: I hope the OP is not doing this. > l = [(d[url],url) for url in d] > l.sort() # l is now in ascending order by count > top50 = l[:50] # and you now take the first 50, which are the ones with the smaller counts. > for count,url in top50: > print url, count
- Previous message (by thread): space-efficient top-N algorithm
- Next message (by thread): space-efficient top-N algorithm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list