This paper presents a deterministic algorithm for the synthesis of sparse arrays with far-field and near-field constraints. Starting from an initial set of possible positions, the algorithm iteratively solves a sequence of convex optimization problems with the objective of minimizing the number of radiating elements among those of the initial set, in presence of constraints on the far-field pattern and on the amplitude of the electric field at prescribed points located in the near-field region of the antenna. The method is suitable for sparse arrays of arbitrary geometry. A numerical example is presented to show the effectiveness of the proposed approach.