index of min element of sequence

Paul Rubin http
Mon Jan 21 20:38:34 CET 2008


Neal Becker <ndbecker2 at gmail.com> writes:
> What's a good/fast way to find the index of the minimum element of a
> sequence?  (I'm fairly sure sorting the sequence is not the fastest
> approach)

Python 2.5 (untested):

   from operator import itemgetter
   minindex = min(enumerate(seq), key=itemgetter(1))[1]



More information about the Python-list mailing list