Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: sorting question

by Enlil (Parson)
on Oct 17, 2004 at 20:04 UTC ( #399963=note: print w/ replies, xml ) Need Help??

in reply to sorting question

This assumes you will have the same amount of x's as y's or you'll get a whole lot of uninitialized warnings (granted there are ways around that):

use strict; use warnings; my $xy = [ [5,4,2,3,1,12], [2,9,2,3,4,5] ]; my @xy; #push x's and corresponding y coor. in #a slight different AoA; for ( 0 .. $#{$xy->[0]} ){ push @xy, [ $xy->[0][$_], $xy->[1][$_] ]; } #sort it by y; @xy = sort { $a->[1] <=> $b->[1] } @xy; print "value of x with largest y = $xy[-1][0]\n"; print "largest y = $xy[-1][1]\n";

Comment on Re: sorting question
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2015-11-27 21:53 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (734 votes), past polls