in reply to sorting and comparing hashes
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" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: two questions that come together into one grand unified question
by Hofmator (Curate) on Oct 15, 2001 at 16:14 UTC |