in reply to Re^2: Array of hash sorting problem
in thread Array of hash sorting problem
foreach(@aoh) { my %a = %$_; my %c= reverse %a;
The problem with reversing the hash is that if the values aren't unique, e.g.
{ 3 => 15, 4 => 8, 5 => 8, },
you won't get the desired result... So why impose unnecessary restrictions for no real gain? For any reasonably sized hash, creating a reversed copy of it will approximately outweigh the benefits of not having to dereference in the sort function.
Also, there's no need to create an extra temp hash %a, just write
my %c = reverse %$_;
|
|---|