def n_max(list, n):
y = range(len(list))
i = sorted(y, key=list.__getitem__)
res = i[len(list)-n:len(list)]
res.reverse()
return res
Wednesday, October 13, 2010
N Maximum Elemens using Python
This method will return N topmost (maximum) elements in a list.
Subscribe to:
Posts (Atom)