I know little about sorting in PERL:

sub SortByIPoccurance { $IPaddr{$a} <=> $IPaddr{$b}; }
@top_hosts = reverse 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.

I tried to wrap my brain around it, but I think Im thinking too much about
it.


Sorted data using the above code
--------------------------------------------------
  13  217.235.11.9
  10  66-42-63-223.lsan.dial.netzero.com
   8  194.131.229.129
   8  82.229.239.18
   4  66.158.232.100
   4  dc-217-85.bpb.bigpond.com
   4  129.177.239.17
   4  12.160.220.3
   4  63.103.169.11
   4  aamiens-152-1-38-182.w83-198.abo.wanadoo.fr
   4  68.142.249.190
   4  68.142.250.40



What Im looking to achieve

cat sort | sort -nrk1,1 -nk2,2
--------------------------------------------------
  13  217.235.11.9
  10  66-42-63-223.lsan.dial.netzero.com
   8  194.131.229.129
   8  82.229.239.18
   4  129.177.239.17
   4  68.142.250.40
   4  68.142.249.190
   4  66.158.232.100
   4  63.103.169.11
   4  12.160.220.3
   4  dc-217-85.bpb.bigpond.com
   4  aamiens-152-1-38-182.w83-198.abo.wanadoo.fr


I realize that PERL output may not be exact.  Im not sure if there are
slight differences in the sorting algorithms.


Thanks
 Birl

Please do not CC me responses to my own posts.
I'll read the responses on the list.

-- 
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