Your example doesn't seem to be a good one because the histogram for most is "1". Is this what you are intending?
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my @AoA =( [qw(TTVVRRRDR KFRQLLWFH RSQSPRRRR CSPHHTALR WIRTPPAYR VVRRR +DRGR HISCLTFGR RTPSPRRRR NTNMGLKFR LVSFGVWIR)], [qw(AILCWGELM TVLEYLVSF GLKFRQLLW LSFLPSDFF LLSFLPSDF LLWFH +ISCL MQLFHLCLI QLFHLCLII ATVELLSFL ALRQAILCW)], [qw(TTVVRRRDR CSPHHTALR WIRTPPAYR NVNMGLKIR LVSFGVWIR HISCL +TFGR)], [qw(CSPHHTALR YVNTNMGLK WIRTPPAYR TLPETTVVR HISCLTFGR NTNMG +LKIR WGMDIDPYK LVSFGVWIR)], ); #calculate histogram my %histo; foreach my $rowref (@AoA) { foreach my $elem (@$rowref) { $histo{$elem}++; } } print Dumper \%histo; #sort each array according to the histogram foreach my $rowref (@AoA) { @$rowref = sort{my $A = $histo{$a}; my $B = $histo{$b}; $A <=> $B} @$rowref; #edit guess should be $B<=> +$A } print Dumper \@AoA; __END__ $VAR1 = { 'WGMDIDPYK' => 1, 'YVNTNMGLK' => 1, 'MQLFHLCLI' => 1, 'KFRQLLWFH' => 1, 'HISCLTFGR' => 3, 'NTNMGLKIR' => 1, 'LVSFGVWIR' => 3, 'QLFHLCLII' => 1, 'VVRRRDRGR' => 1, 'WIRTPPAYR' => 3, 'LLSFLPSDF' => 1, 'TVLEYLVSF' => 1, 'CSPHHTALR' => 3, 'NTNMGLKFR' => 1, 'LLWFHISCL' => 1, 'LSFLPSDFF' => 1, 'AILCWGELM' => 1, 'TTVVRRRDR' => 2, 'NVNMGLKIR' => 1, 'RSQSPRRRR' => 1, 'ALRQAILCW' => 1, 'GLKFRQLLW' => 1, 'ATVELLSFL' => 1, 'TLPETTVVR' => 1, 'RTPSPRRRR' => 1 }; $VAR1 = [ [ 'KFRQLLWFH', 'RSQSPRRRR', 'VVRRRDRGR', 'RTPSPRRRR', 'NTNMGLKFR', 'TTVVRRRDR', 'CSPHHTALR', 'WIRTPPAYR', 'HISCLTFGR', 'LVSFGVWIR' ], [ 'AILCWGELM', 'TVLEYLVSF', 'GLKFRQLLW', 'LSFLPSDFF', 'LLSFLPSDF', 'LLWFHISCL', 'MQLFHLCLI', 'QLFHLCLII', 'ATVELLSFL', 'ALRQAILCW' ], [ 'NVNMGLKIR', 'TTVVRRRDR', 'CSPHHTALR', 'WIRTPPAYR', 'LVSFGVWIR', 'HISCLTFGR' ], [ 'YVNTNMGLK', 'TLPETTVVR', 'NTNMGLKIR', 'WGMDIDPYK', 'CSPHHTALR', 'WIRTPPAYR', 'HISCLTFGR', 'LVSFGVWIR' ] ];

In reply to Re: Sort array using a ranking system from separate hash by Marshall
in thread Sort array using a ranking system from separate hash by Sandy_Bio_Perl

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.