in reply to Retrieving data with largest count
my %largest; while (<>) { my ($item, $group_id, $count) = split; next if $largest{$group_id} && $largest{$group_id}[2] >= $count; $largest{$group_id} = [ $item, $group_id, $count, $_ ]; } for (values(%largest)) { print($_->[-1]); }
Keeps first on ties.
Update: Added note at bottom.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Retrieving data with largest count
by Limbic~Region (Chancellor) on Jun 02, 2009 at 15:25 UTC | |
by ikegami (Patriarch) on Jun 02, 2009 at 15:43 UTC | |
by Limbic~Region (Chancellor) on Jun 02, 2009 at 17:23 UTC | |
by ikegami (Patriarch) on Jun 02, 2009 at 17:29 UTC |