in reply to How to sort IP addresses
This is one of the example sorts in Uri Guttman and Larry Rosler's paper on sorting in Perl.
They use the following:
@out = sort { pack('C4' => $a =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/) cmp pack('C4' => $b =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/) } @in;
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
|
|---|