Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Sorting ip addresses quicker

by gryng (Hermit)
on Jul 14, 2000 at 05:47 UTC ( [id://22484]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @sorted = map  { $_->[0] }
                 sort { $a->[1] <=> $b->[1] }
                 map  { [$_, int sprintf("%03.f%03.f%03.f%03.f", split(/\.
    +/, $_))] }
                 @unsorted;
    
  2. or download this
    Loading ips
    Loaded 1000 ips
    Benchmark: running Fastnum, Faststr, each for at least 10 CPU seconds.
    +..
       Fastnum: 11 wallclock secs (11.28 usr +  0.00 sys = 11.28 CPU) @  7
    +.98/s (n=90)
       Faststr: 12 wallclock secs (11.34 usr +  0.00 sys = 11.34 CPU) @  8
    +.29/s (n=94)
    
  3. or download this
    my @sorted = map { $_->[0] }
                 sort { $a->[1] <=> $b->[1] }
    ...
                            $x=$_ + $x * 256 for split(/\./, $y);
                            [$y,$x]}
                 @unsorted;
    
  4. or download this
    Loading ips
    Loaded 1000 ips
    Benchmark: running Faster, Faststr, each for at least 10 CPU seconds..
    +.
        Faster: 11 wallclock secs (11.09 usr +  0.00 sys = 11.09 CPU) @ 12
    +.98/s (n=144)
       Faststr: 11 wallclock secs (11.24 usr +  0.00 sys = 11.24 CPU) @  8
    +.27/s (n=93)
    
  5. or download this
    Loading ips
    Loaded 100000 ips
    ...
        Faster: 58 wallclock secs (57.90 usr +  0.21 sys = 58.11 CPU)
       Fastnum: 83 wallclock secs (82.57 usr +  0.38 sys = 82.95 CPU)
       Faststr: 83 wallclock secs (82.74 usr +  0.00 sys = 82.74 CPU)
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://22484]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 09:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found