my @keys = map { $_->[1] } sort { $a->[0] cmp $b->[0] } map { [sprintf('%03d' x 4, split /\./, $temphash{$_}->{IP}), $_] } keys %temphash;