use
strict;
use warnings;
use Data :: Dumper;
my %hash ;
my %prod ;
my %prod2 ;
while ( < DATA > ) {
my ( $a , $b ) = split ;
push @{ $hash { $b } } , $a ;
$prod { $a } = $b ;
}
my $i = scalar keys %hash ;
for my $e ( sort { $b <=> $a } keys %hash ) {
for my $pid ( @{ $hash { $e } } ) {
print " $pid $i " ;
$prod2 { $pid } = $i ;
}
$i -- ;
}
print " - " x 20 , $ / ;
for my $pid ( sort { $prod2 { $b } <=> $prod2 { $a }} keys %prod ) {
print " $pid $prod{$pid} $prod2{$pid} " ;
}
__DATA__
100 15
101 14
102 14
103 200
104 2
105 2
106 1
use warnings;
use Data :: Dumper;
my %hash ;
my %prod ;
my %prod2 ;
while ( < DATA > ) {
my ( $a , $b ) = split ;
push @{ $hash { $b } } , $a ;
$prod { $a } = $b ;
}
my $i = scalar keys %hash ;
for my $e ( sort { $b <=> $a } keys %hash ) {
for my $pid ( @{ $hash { $e } } ) {
print " $pid $i " ;
$prod2 { $pid } = $i ;
}
$i -- ;
}
print " - " x 20 , $ / ;
for my $pid ( sort { $prod2 { $b } <=> $prod2 { $a }} keys %prod ) {
print " $pid $prod{$pid} $prod2{$pid} " ;
}
__DATA__
100 15
101 14
102 14
103 200
104 2
105 2
106 1