The thermodynamics as well as the energetics and the structural properties of cubic group-III nitrides alloys have been investigated by combining first-principles total energy calculations and cluster expansion methods. In particular results are shown for the ternary In x Ga 1−x N and the quaternary Al x Ga y In 1−x−y N alloys. Phase separation is predicted to occur at growth temperatures, for both fully relaxed alloys. A remarkable influence of an external biaxial strain on the phase separation, with the formation of ordered phase structures has been found for the InGaN alloy. These findings are used to clarify the origin of the light emission process in InGaN-based optoelectronic devices. Results are shown for the composition dependence of the lattice constant and of the energy gap in quaternary Al x Ga y In 1−x−y N alloys.