A new algorithm for the solution of multimaterial topology optimization problems is introduced in the present study. The presented method is based on the splitting of a multiphase topology optimization problem into a series of binary phase topology optimization sub-problems which are solved partially, in a sequential manner, using a traditional binary phase topology optimization solver; internal solver. The coupling between these incomplete solutions is ensured using an outer iteration strategy based on the block coordinate descend method. The presented algorithm provides a general framework to extend the traditional binary phase topology optimization solvers for the solution of multiphase topology optimization problems. The overall algorithmic complexity of the presented algorithm is independent of the number of desired phases, $\mathtt{p}$, and its computational cost is approximately proportional to $\mathtt{p^2}$. The interesting features of the presented algorithm are: generality, simplicity, efficiency, ease of implementation and the inheritance of the convergence properties of its internal optimization solver. The presented algorithm is used to solve multimaterial minimum structural and thermal compliance topology optimization problems based on the classical optimality criteria method. The details of MATLAB implementation are presented and the complete program listings are provided as the supplementary materials. The success and performance of the presented method are demonstrated through several two dimensional numerical examples.