This should work for you, if you wanted it sorted by values. If you wanted keys, just change the first for loop to add keys rather than values to the arrays. Enjoy.
my @files; my @plays; for (keys %filelist) { $files[@files] = $filelist{$_}; $plays[@plays] = $playlist{$_}; } my @sorted = (0 .. $#files); @sorted = sort {$files[$a] cmp $files[$b]} @sorted; @files = @files[@sorted]; @plays = @plays[@sorted]; for (my $i=0; $i<@files; $i++) { print "$files[$i] \<\=\> $plays[$i]\n" }
In reply to Re: two questions that come together into one grand unified question
by jryan
in thread sorting and comparing hashes
by ashaman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |