Hi,
I'm a newbie in perl (also in programming), so I'll try to explain myself...
I have an array of hashes with the following structure
$matrix[0]{A} = 22
...
$matrix[1]{C} = 30
...
...
[A->22, C->51, G->7, T->0]
[A->9, C->30, G->0, T->2]
[and so on ]
I want to sort each row in another array of arrays by the values of each hash, but keeping the information of the letter. For instance:
@sorted[][]
[ 51 22 7 0 C A G T ]
[ 30 9 2 0 C A T G ]
...
So i can relate 51 with C, 22 with C, etc.
Thanks in advance!
I tried to do the thing that kennethk proposes but i got lost in the syntax because It's a hash into an array.
@sorted = sort { {$a} <=> {$b} } keys @matrix[$pos]{};
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.