in reply to Re^2: Sorting an array of anonymous hashes with named hashes using hash value
in thread Sorting an array of anonymous hashes with named hashes using hash value

Much trickier than I thought. Thanks!

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

  • Comment on Re^3: Sorting an array of anonymous hashes with named hashes using hash value

Replies are listed 'Best First'.
Re^4: Sorting an array of anonymous hashes with named hashes using hash value
by haukex (Archbishop) on May 07, 2016 at 12:22 UTC

    Hi nysus,

    There is one caveat to the AM's code: because hash ordering is random, ( values %$_ )[0] picks a random value from that hash. So if I change your example data structure like so: $places->[0]{123}{name} = "Alpha";, the sort will give random results. So if you use that sort method, make sure that you know each hash at that level only has one key.

    Hope this helps,
    -- Hauke D