Greetings monks, I have a bunch of data that refers to a single thing. I need to choose the best representation of that single thing by using the qualities of the multiple different measurements. Due to the fact that I have to do about 3k of these things, the data structure has become a hash of a hash of a hash. ie: $hash{$individual thing}{multiple measurements of individual thing}{qualities of current measurement}. for example:
$data{$name}{$measurement}{'SIZE'} = $size
I have ~3k of $name, and around 5 of measurement for each $name and there are 10 qualities such as size. In order to select the "best" one of these measurements for each name, I need to do some sort of selection on several of the different qualities. Thus, it seems I need to sort the inner hash. However, I'm not sure how to sort the qualities into descending order and keep the mapping of which measurement the quality applies to. For example: Name 1 has 5 measurements. The 5 measurements have SIZEs of 100, 200, 300, 400, and 500. If I want to order on the SIZE quality, how do I do this? It'd be great if this would work on qualities that are numbers and letters. Esentially I need to order the 10 different qualities in a variety of ways to find the "best" representation by those qualities. I'm more than happy to change the data structure if someone can recommend something better (I heard mention of AoA in the chatbox, but I'm not sure how to keep the measurement qualities separate in an AoA).
Thanks.
Ineff

In reply to Choosing "best" - sorting hashes issue by Ineffectual

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.