in reply to Re: Sorting an array of hashes and filenames
in thread Sorting an array of hashes and filenames

(By the way: You could make the key the filename, depending on what else you were doing in the code. Just use 'values' instead of 'keys' above.)

Not really. You can get the value from the key, but not the other way around. To sort by value you need something like this:
foreach my $hash ( sort {$file_hashes{$a} cmp $file_hashes{$b}} keys %file_hashes ) { print "$hash $file_hashes{$hash}\n"; }

Replies are listed 'Best First'.
Re^3: Sorting an array of hashes and filenames
by DStaal (Chaplain) on Jan 14, 2009 at 16:07 UTC

    Good point. I must have twisted my brain by the time I got around to writing that.