We report the results of the systematic investigation into correlations between energetics and hexagonal stacking configurations for carbon, silicon, SiC, BN, AlN, GaN, and InN polytypes with sp3-bonded networks. The atomistic geometry, energetics, and electronic structure for these compounds with up to the periodic stacking length of L = 8 have been carefully calculated based on the density functional theory within the generalized gradient approximation (GGA). Using the Axial Next-Nearest-Neighbor Ising model extracted from the GGA calculations, we have also studied the energetics for more than 6 million kinds of nonequivalent stacking polytypes with up to L = 30, whose configurations have been deduced by the efficient polytype generation algorithm [E. Estevez-Rams and J. Martinez-Mojicar, Acta Crystallogr., Sect. A: Found. Crystallogr. 64, 529 (2008)], and illustrated some trends of structural and energetic properties for these compounds.