My best guess as to your meaning is that column 1 is the frequency of the value in column 3.

Here's one way that might be coded:

#! perl -slw use strict; my @data; push @data, [ split ] while <DATA>; @data = sort { $a->[ 0 ] * $a->[ 2 ] <=> $b->[ 0 ] * $b->[ 2 ] } @data; print "Lowest: ". join "\t", @{ $data[ 0 ] }; print "Highest:", join "\t", @{ $data[-1 ] }; __DATA__ 2870 S11 1 574 S11 2 317 S11 3 31 S11 4 1 S11 6 1 S11 7 2925 S12 1 8 S12 5 1 S12 6 1 S12 9

And the output is:

c:\test>junk37 Lowest: 1 S11 6 Highest:2925 S12 1

As both groups of data have 1 x 6 values, either (or both) are candidates for the 'lowest', so you'll have to decide which through some further qualification to the sort: eg. you might consider that in the event of a tie S11 is 'lower' than S12. Or, you might decide to display both (all) equally low values.

Of course, if the set of values is large, especially if it is larger than memory, sorting is an inefficient way of find the largest and smallest. The main point is that (assuming I understood you correctly) that you need to multiply column 1 by column 3 when doing your comparisons.

Feel free to ask questions about this code. It is easier to answer specific questions than guess what you might not know.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: max and min values in 3-column file by BrowserUk
in thread max and min values in 3-column file by perldummie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.