Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How can I find the index of the biggest element in an array?

by salva (Canon)
on May 27, 2007 at 22:15 UTC ( [id://617774]=note: print w/replies, xml ) Need Help??


in reply to How can I find the index of the biggest element in an array?

and if what you need are the indexes for the $n biggest elements:
use Sort::Key::Top qw(nkeytop rnkeytop); my @data = ( 100, -2, 5, 12, 1, 1, 6786, ...); my @min_ix_n = nkeytop { @data[$_] } $n => 0..$#data; my @max_ix_n = rnkeytop { @data[$_] } $n => 0..$#data;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://617774]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-25 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found