You can use Tie::Hash::Array to ensure that a hash is sorted.
Added:
Limbic~Region brought up that you need a hash of hashes sorted. Here is a simple example of how to use this with Data::Dumper.
use Tie::Hash::Array; tie my %hash, 'Tie::Hash::Array'; foreach(a..z){ tie my %tmp, 'Tie::Hash::Array'; my $t = $_; foreach my $i(0..5){ $t++; $tmp{$t} = $i; } $hash{$_} = \%tmp; } use Data::Dumper; print Dumper \%hash; untie %hash; __OUTPUT__ $VAR1 = { 'a' => { 'b' => 0, 'c' => 1, 'd' => 2, 'e' => 3, 'f' => 4, 'g' => 5 }, 'b' => { 'c' => 0, 'd' => 1, 'e' => 2, 'f' => 3, 'g' => 4, 'h' => 5 }, 'c' => { 'd' => 0, 'e' => 1, 'f' => 2, 'g' => 3, 'h' => 4, 'i' => 5 }, 'd' => { 'e' => 0, 'f' => 1, 'g' => 2, 'h' => 3, 'i' => 4, 'j' => 5 }, 'e' => { 'f' => 0, 'g' => 1, 'h' => 2, 'i' => 3, 'j' => 4, 'k' => 5 }, 'f' => { 'g' => 0, 'h' => 1, 'i' => 2, 'j' => 3, 'k' => 4, 'l' => 5 }, 'g' => { 'h' => 0, 'i' => 1, 'j' => 2, 'k' => 3, 'l' => 4, 'm' => 5 }, 'h' => { 'i' => 0, 'j' => 1, 'k' => 2, 'l' => 3, 'm' => 4, 'n' => 5 }, 'i' => { 'j' => 0, 'k' => 1, 'l' => 2, 'm' => 3, 'n' => 4, 'o' => 5 }, 'j' => { 'k' => 0, 'l' => 1, 'm' => 2, 'n' => 3, 'o' => 4, 'p' => 5 }, ....

- Tom


In reply to Re: Sort-Tying all hashes in a hash of hashes by tcf22
in thread Sort-Tying all hashes in a hash of hashes by welchavw

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.