The court before which a person is tried for an offence under this Act in respect of an animal may order (a) that any animal or conveyance detained under section 17 or 18 continue to be detained until (i) any monetary penalties imposed by the court are paid; and(ii) the costs and expenses connected with taking possession of the animal or conveyance and detaining it are paid; and(b) that in default of payment of any amount referred to in paragraph (a) within a time specified by the court, the animal or conveyance be sold and the proceeds of the sale be distributed in accordance with section 46 .