The general reason you are having problems is that you are trying to sort both the hashes and the filenames, as if they were equivalent items. They aren't: They are related.
This calls for a Perl hash, which keeps related things together.
I've been trying to adapt one into your code for five minutes or so, and have come to the conclusion that either I don't understand line 3, or there is something completely screwy with your code snippit.
Therefore, pseudo-code to do what you want:
my %file_hashes; foreach my $file ( #List_of_files ) { my $hash = hash_fuc($file); $file_hashes{$hash} = $file; } foreach my $hash ( sort keys %file_hashes ) { print "$hash $file_hashes{$hash}\n"; }
You'll probably want to read up on hashes in Perl. They are useful.
(Edit: Removed brainfart at the end.)
In reply to Re: Sorting an array of hashes and filenames
by DStaal
in thread Sorting an array of hashes and filenames
by learningperl01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |