use Sort::Key::IPv4 qw(netipv4keysort); my %hash = ( '127' => { 'network' => '10.182.48.0/24', 'VLAN' => '3509' }, ...); my @sorted_keys = netipv4keysort { $hash{$_}{network} } keys %hash;