Hi monks! I facing a problem what it should be easy to fix it but i don't know how. I have a script which opens a lot of log files and pull the data to different hashes. For the sake of organization, i translate the dates to epoc and organize in my hash the info using the epoc time as the second hash, to prevent duplicates and to sort the hash results to present them in chronologic order. Well, the problem its sort isn't sorting epoc numbers :(
foreach $cat ( keys %data ) { foreach $date ( keys %{ $data{$cat} }) { print "<tr>"; foreach $data_type (sort { $a cmp $b } keys %{ $data{$cat}{$da +te} } ) { print "<td align='left'>$data{$cat}{$date}{$data_type}</td +>"; #print "<br>"; } print "</tr>"; } }
$cat = category, i have 4, that runs. $date = its the date en epoc, this doesn't run $date_type = the type of data we are going to print, this works. The results of the sort that is not shorting are:
EPOC IP 1405799856 79.223.46.211 1405879428 79.200.95.44 1405702121 87.149.76.154 1407101135 188.138.41.140 1406108233 82.139.192.95 1407162997 87.149.66.39 1405810508 80.187.110.214 1405791762 84.159.197.17 1405870826 2.246.106.240 1406040423 87.154.119.73 1405810525 85.22.101.198 1405620262 87.149.72.59 1405603261 178.12.215.30 1405806556 80.187.102.26
As you can see, there is not sorting. :(

In reply to sort on hash / hash / hash doesn't work by PsySkeletor

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.