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