http://www.perlmonks.org?node_id=1030762

supriyoch_2008 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perlmonks,

I have two arrays i.e. @x and @y containing eight names and eight numerical values, respectively. Each name in @x corresponds to the particular value in @y at the specific position. I am interested in finding out five maximum values with positions in @y in descending order and five minimum values with positions in @y in ascending order. I am at my wit's end to find it. I can find out only the maximum and minimum value from the array @y. I seek the wisdom of perlmonks in this matter. I have given the two arrays below:

@x = qw/c d e f k l m n/; @y = qw/4 6 5 2 9 7 8 3/;

The desired results should look something like:

Max values (only 5) in descending order with positions in name array: 9 corresponds to k at position 4 8 corresponds to m at position 6 7 corresponds to l at position 5 6 corresponds to d at position 1 5 corresponds to e at position 2 Min values (only 5) in ascending order with positions in name array: 2 corresponds to f at position 3 3 corresponds to n at position 7 4 corresponds to c at position 0 5 corresponds to e at position 2 6 corresponds to d at position 1