School finance ruling favors districts