$ echo "1300018 a1 1300019 a1 1300100 a2 1300101 a2 1300126 a2 1300127 a2 1300128 a2 1300129 a2 1300130 a3 1300131 a3 1300132 a3 1300133 a3" | perl -lane' push @order, $F[ 1 ] unless $h{ $F[ 1 ] }; push @{ $h{ $F[ 1 ] } }, "$F[ 0 ]\n" }{ print "$_ " . @{ $h{ $_ } } . "file\n", @{ $h{ $_ } } for @order ' a1 2file 1300018 1300019 a2 6file 1300100 1300101 1300126 1300127 1300128 1300129 a3 4file 1300130 1300131 1300132 1300133

In reply to Re: question about algorithm by jwkrahn
in thread question about algorithm by cxfcxf

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.