#!/usr/bin/perl
#
while ($package=<STDIN>) {
	chomp $package;
	$priority=`grep-available -F Package -s Priority -X $package`;
	$priority=~ s/^Priority: //;
	chomp $priority;
	if ( $priority ne "" ) {
		push @{$list{$priority}}, $package;
		$number{$priority}++;
	}
}

foreach $priority ( keys %number ) {
	print "-" x 40;
	print "\n";
	print "Packages for priority '$priority': \n";
	print "-" x 40;
	print "\n";
	while ($package = pop @{$list{$priority}} ) {
		print $package."\n";
	}
}

exit 0;
