  This paper is dedicated to the spectral optimization problem
\begin{equation*} \min \big\{ \lambda_1(\Omega)+\cdots+\lambda_k(\Omega) +
\Lambda|\Omega| \ : \ \Omega \subset D \text{ quasi-open} \big\}
\end{equation*} where $D\subset\mathbb{R}^d$ is a bounded open set and
$0<\lambda_1(\Omega)\leq\cdots\leq\lambda_k(\Omega)$ are the first $k$
eigenvalues on $\Omega$ of an operator in divergence form with Dirichlet
boundary condition and H\"{o}lder continuous coefficients. We prove that the
first $k$ eigenfunctions on an optimal set for this problem are locally
Lipschtiz continuous in $D$ and, as a consequence, that the optimal sets are
open sets. We also prove the Lipschitz continuity of vector-valued functions
that are almost-minimizers of a two-phase functional with variable
coefficients.
