(2) Any person sentenced to imprisonment for the violation of an ordinance may be imprisoned in the jail of such city; or, if the council by ordinance so prescribes, in the county jail of the county in which such city is situated, in which case the expense of imprisonment shall be a charge in favor of such county and against such city. Before any such person can be imprisoned in the county jail, the consent of the county court shall be first obtained.