I can't believe I am asking for enhanced wisdom so soon after having asked for it before!

I just ran into what seems a conundrum, but I am sure it is simply an example of lack of coding expertise.

I am writing this code for work that includes a series of the following values. Two strings, each of which are unique and a numeric, which need not be unique. My desire is for the final output to be to list each string value and their corresponding numeric value in descending order of the numeric value.

I thought to use a hash where I concatenate the strings with some delimeter and use that as the key setting. And then let the value portion of the hash be the numeric.

And after the hash is fully populated, reverse sort the value setting into an array.

I have two questions.

1) What is the best way to "ask" for the setting of the key given a setting for the value? (I figured to just loop through the array with my output portion of the code.)

2) What of the case of more than one key,value pair having the same numeric value for the value? How does one code for extracting each key,value pair for output?

Tony

In reply to Hashes: Obtaining the Key Value for a Given Value Value by o2bwise

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.