Is there some function which would return me the N highest elements from some list?
I.e. if max(l) returns the single highest element, sth. like m
max(l)
m
heapq.nlargest:
>>> import heapq, random >>> heapq.nlargest(3, (random.gauss(0, 1) for _ in xrange(100))) [1.9730767232998481, 1.9326532289091407, 1.7762926716966254]