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?? |
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;
In Section
Meditations
|
|