Theory of ordering of ternary substitutional solid solutions