Posted By

alfirth on 03/03/11


Tagged


Versions (?)

Sort by IPv4


 / Published in: Perl
 

  1. my @sorted_ips = #sort by ip
  2. map substr($_, 4) =>
  3. sort map pack('C4' =>
  4. split /\./)
  5. . $_ => (@unsorted_ips);

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: salva on March 9, 2011

use Sort::Key::IPv4 qw(ipv4sort); my @sortedips = ipv4sort @unsortedips

You need to login to post a comment.