The order issued by a federal judge in Boston also directs officials to reinstate thousands of fired employees.