nysus has asked for the wisdom of the Perl Monks concerning the following question:
I'm having a mental block and hoping someone can help me out. I have the following data structure (an array of anonymous hashes with a named hash inside each anonymous hash):
[ { '221479714642518' => { 'name' => 'Family Mobile Phone and Ta +blet Repair', 'link' => 'https://www.facebook.com/F +amilyMobileRepairs/' } }, { '1626748754240747' => { 'name' => 'Bows and Baubles by Morga +n', 'link' => 'https://www.facebook.com/ +bowsandbaublesbymorgan/' } } ];
I want to sort the array based on the name key inside the inner hash. I'm trying something like this:
my @sorted_places = sort { $places->$a->{name} cmp $places->$b->{name} + } map { keys %$_ } @$places;
I get an error:
Can't call method "221479714642518" on unblessed referenceI've tried several different things but no luck. Any help is appreciated.
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting an array of anonymous hashes with named hashes using hash value
by AnomalousMonk (Archbishop) on May 07, 2016 at 00:04 UTC | |
|
Re: Sorting an array of anonymous hashes with named hashes using hash value
by Anonymous Monk on May 07, 2016 at 00:04 UTC | |
by Anonymous Monk on May 07, 2016 at 00:07 UTC | |
by nysus (Parson) on May 07, 2016 at 12:06 UTC | |
by haukex (Archbishop) on May 07, 2016 at 12:22 UTC |