[Numpy-discussion] Find indices of largest elements

Nikolaus Rath Nikolaus at rath.org
Wed Apr 14 11:16:02 EDT 2010


Hello,

How do I best find out the indices of the largest x elements in an
array?

Example:

a = [ [1,8,2], [2,1,3] ]
magic_function(a, 2) == [ (0,1), (1,2) ]

Since the largest 2 elements are at positions (0,1) and (1,2).


Best,

   -Niko

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C




More information about the NumPy-Discussion mailing list