I have the following input data, showing only a few lines:

Pos A C G T 0 4 0 13 0 1 5 0 12 0 2 15 0 2 0 3 0 17 0 0

I stored that data into an array of hashes called @matrix. For instance $matrix[0]{A}=4 and so on.

I want to sort each line from highest frequency to lowest frequency and store it in another array of arrays, but I also need to remember wich letter corresponds to each number

I thought it would be a good idea to store the nucleotide order at the end of the array, here is an example with the first lines that i would like to obtain:

First number is original position. I put it there because then i would like to sort the matrix by the top most score of each row.

[0 13 4 0 0 G A C T] [1 12 5 0 0 G A C T] [2 15 2 0 0 A G C T] [3 17 0 0 0 C A G T]

I hope it's more clear now...


In reply to Re^2: Complex sort of array of hashes into an array of arrays by BioJL
in thread Complex sort of array of hashes into an array of arrays by BioJL

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.