Tuesday, January 17, 2006

Sort IP Address with PERL

@out = sort {
pack('C4' => $a =~
/(\d+)\.(\d+)\.(\d+)\.(\d+)/)
cmp
pack('C4' => $b =~
/(\d+)\.(\d+)\.(\d+)\.(\d+)/)
} @in;


http://www.sysarch.com/Perl/sort_paper.html