Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

RE: Sorting a list of IP addresses (aka Why I hate Big O)

by dws (Chancellor)
on Aug 03, 2000 at 04:05 UTC ( [id://25885]=note: print w/replies, xml ) Need Help??


in reply to Sorting a list of IP addresses (aka Why I hate Big O)

It doesn't change the O'ness, but this looks like a job for the Orcish maneuver.
my %cache = ();
my @sorted = sort {
        $cache{$a} ||= pack('C4' => $a =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/);
        $cache{$b} ||= pack('C4' => $b =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/);
        $cache{$a} cmp $cache{$b};
} @unsorted;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-03-28 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found