Any committing judge of the district court of any county where there is no sufficient jail may order any person whom they may lawfully order to be committed to prison to be sent to the jail of the nearest county that has sufficient space and means to care for the inmate as determined by the sheriff or keeper of the jail of such nearest county. The sheriff of such nearest county shall, on exhibit of the order of such judge that contains a statement that there is no sufficient jail in such judge’s county, receive and keep in custody in the jail of such sheriff’s county the prisoner ordered to be committed, at the expense of the county from which such person was sent. The sheriff of the county ordering commitment is responsible for transportation of the prisoner.