A projected Lagrangian algorithm and its implementation for sparse nonlinear constraints