my %revhash; push @{$revhash{$hash{$_}}}, $_ for keys %hash; for (sort keys %revhash) { print "$_ => @{$revhash{$_}}\n"; }