Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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";

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 contemplating the Monastery: (9)
As of 2016-10-25 20:48 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (330 votes). Check out past polls.