It's relatively basic, bu I've not been able to crack this from the quite repetitive help (same examples) that turn up everywhere based on perldoc.

Here's the code. Sorry if you'd have preferred without the html, but I thought it might make the job clearer - 'paste and go'.

Many thanks for any advice.
Bob H

------- #!/usr/bin/perl use CGI qw(:standard); print header; print start_html('hash of arrays'); print "<font size = +1><b>Sorting a hash of arrays by one of array ite +ms</b>\n"; print "<p>Add data with each data set in one array ...\n"; my %hoa = ( "array a" => [ "data a0", "data a1", "data a2", "data a3" ], "array b" => [ "data b0", "data b1", "data b2", "data b3" ], "array c" => [ "data c0", "data c1", "data c2", "data c3" ], ); print "<br>... done\n"; #------------------------- print "<p>Display data, without sorting ...\n"; print "<table border=1 bgcolor=AAAAFF>\n"; print "<tr><td bgcolor=FF99FF>hash</td><td bgcolor=FF99FF>data 0</td>< +td bgcolor=FF99FF>data 1</td><td bgcolor=FF99FF>data 2</td><td bgcolo +r=FF99FF>data 3</td></tr>\n"; for $data ( keys %hoa ) { print "<tr><td>$data:</td>\n"; for $i ( 0.. $#{ $hoa{$data} } ) { print "<td> $i = $hoa{$data}[$i] </td>"; } print "</tr>\n"; } print "</table>\n"; #------------------------- print "<p>Display data, sorted by 'hash' ...\n"; print "<table border=1 bgcolor=AAAAFF>\n"; print "<tr><td bgcolor=FF99FF>hash</td><td bgcolor=FF99FF>data 0</td>< +td bgcolor=FF99FF>data 1</td><td bgcolor=FF99FF>data 2</td><td bgcolo +r=FF99FF>data 3</td></tr>\n"; for $data ( sort ( keys %hoa ) ) { print "<tr><td>$data:</td>\n"; for $i ( 0.. $#{ $hoa{$data} } ) { print "<td> $i = $hoa{$data}[$i] </td>"; } print "</tr>\n"; } print "</table>\n"; #------------------------- print "<p>Display data, sorted by array 0 ...\n"; print "<p>help please!\n"; print "</font>\n"; print end_html; ------------

In reply to ordering a hash of arrays by an array contents by Bob H

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.