my %by_id; push @{ $by_id{ $_->{id} } }, $_->{score} for @data; # Sort the scores for each id. $_ = [ sort { $b <=> $a } @$_ ] for values %by_id; # Sort the ids by the highest score. for my $id (sort { $by_id{$b}[0] <=> $by_id{$a}[0] } keys %by_id) { print "ID: $id\tScore: $_\n" for @{ $by_id{$id} }; }
In reply to Re: Sorting Complex Data Structure
by choroba
in thread Sorting Complex Data Structure
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |