my @x = @{$xy->[0]}; my @y = @{$xy->[1]}; my $i = 0; my %xyhash; foreach ( @x ) { $xyhash{ $_ } = $y[$i]; $i++ } my @x_sorted_by_y = sort{ $xyhash{$b} <=> $xyhash{$a} } keys %xyhash; my @sorted_y = sort{ $b <=> $a } @y; print "value of x with largest y = $x_sorted_by_y[0]\n"; print "largest y = $sorted_y[0] \n";