Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

Chris Rebert crebert at ucsd.edu
Thu Apr 22 10:04:01 EDT 2010


2010/4/22 Jo Chan <csjcg2 at gmail.com>:
> Hi,friends.
>  I wanna ask if there is a function which is able to take a list as argument
> and then return its top-k maximums?
> I only know about max which is poorly a top-1 maximum function, now I want
> more yet I am lazy enough that don't want to write one by myself.

http://docs.python.org/library/heapq.html#heapq.nlargest

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list