Here a proof of concept: (stealing data from AppleFritter's example)

#!/usr/bin/perl use strict; use warnings; use feature qw/say/; use Data::Dump qw/pp dd/; my %data = ( "key0.1" => [ { "key1.1" => 3.3, "key1.2" => 17.8, "key1.3" => -2.4, }, { "key1.4" => 5.1, "key1.5" => 13, }, { "key1.6" => -69, "key1.7" => 127, "key1.8" => 2.718, "key1.9" => 3.3, }, ], "key0.2" => [ { "key1.10" => 3.3, "key1.11" => 2.5, }, { "key1.12" => -33, }, ], ); my %flat = (); while (my ($k0,$v0) = each %data) { my $k1=-1; for my $v1 (@$v0) { $k1++; while (my ($k2,$v2) = each %$v1) { $flat{$k0,$k1,$k2} = $v2; } } } my @sorted_keys = sort { $flat{$a} <=> $flat{$b} } keys %flat; for my $k (@sorted_keys) { my $v = $flat{$k}; say "$v \t<= \t", join ", ", split ( $; , $k ); }

Output:

-69 <= key0.1, 2, key1.6 -33 <= key0.2, 1, key1.12 -2.4 <= key0.1, 0, key1.3 2.5 <= key0.2, 0, key1.11 2.718 <= key0.1, 2, key1.8 3.3 <= key0.1, 0, key1.1 3.3 <= key0.1, 2, key1.9 3.3 <= key0.2, 0, key1.10 5.1 <= key0.1, 1, key1.4 13 <= key0.1, 1, key1.5 17.8 <= key0.1, 0, key1.2 127 <= key0.1, 2, key1.7

HTH! =)

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)


In reply to Re^2: sorting hash of array of hashes by value by LanX
in thread sorting hash of array of hashes by value by Special_K

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.