Help for this page
sub ip_to_key { sprintf "%03d", split /\./, $_[0] } my @sortedKeys = sort { ip_to_key($ipaddr{$a}) cmp ip_to_key($ipaddr{$b}) } keys %ipaddr;
my @sortedKeys = map substr($_, 4), sort map pack('C4', split(/\./, $ipaddr{$_})) . $_, keys %ipaddr;