S.A. Birl wrote:
I know little about sorting in PERL:

sub SortByIPoccurance { $IPaddr{$a} <=> $IPaddr{$b}; }
@top_hosts = reverse sort SortByIPoccurance (keys %IPaddr);

If you want the reverse order then do it in the sub used by sort:

sub SortByIPoccurance { $IPaddr{$b} <=> $IPaddr{$a} }
@top_hosts = sort SortByIPoccurance keys %IPaddr;


print "Frequently connecting hosts (# of http/s hits):\n";
print "----------------------------------------------------------- \n";
foreach $hosts (@top_hosts)
{
        printf("%4d  %s\n", $IPaddr{$hosts}, $hosts);
}
print "\n\n";


But what I want to do now is reverse sort column 1 then sort the hostnames/IPs in column 2. I have the correct Solaris 9 command.

sub SortByIPoccurance { $IPaddr{ $b } <=> $IPaddr{ $a } || $a cmp $b }



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to