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
In reply to Re: How to sort IP addresses
by davorg
in thread How to sort IP addresses
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |