@wallpaperone=("Quick Goo","17 Votes","6.792");
@wallpapertwo=("Cool Planet","25 Votes","3.6");
is there a way I can sort these by the third value(Average Rating) in the array, then print something like this:
1. Quick Goo
17 Votes
Rated 6.792
2. Cool Planet
25 Votes
Rated 3.6
The only problem is that I can't order @wallpaperone and @wallpaper two then retrieve the second and third values, because they might change. I know I have severely underexplained this, so here it is in a nutshell:
I have twenty wallpapers, all of which have results stored in their own independent text files. They look like this when read: Palanet¦134¦7.5 . I need to sort them all by the last value (7.5 in this case), then display the top ten, along with not only each of the individual wallpaper's rating, but along with its name and number of votes, too. Thanks a whole lot in advance.
Make sure to change ¦ to actual pipe symbols. Forum software, automatically replaces them to the broken pipe symbol.
You need to at least give it your best effort first as these forums are designed to help you learn perl, not have somebody else do it for you. Please have a look at the Charter [webmasterworld.com] for posting guidelines.
my @wp_data_sorted = sort {
(split '\¦', $b, 3)[2] <=>
(split '\¦', $a, 3)[2]
} @wp_data;
and
for ( my $i=0; $i<10; $i++ ) {
my ($name, $votes, $rating) =
split '\¦', $wp_data_sorted[$i], 3;