The amount of the cost of vacating and closing or removal or demolition by the code and ordinance enforcement officer shall be a lien against the real property upon which such cost was incurred. This lien shall attach to the real property upon the payment of all costs of demolition by the county and the filing of an itemized statement of the total sum of these costs by the code and ordinance enforcement officer in the office of the county clerk on a lien docket maintained by the clerk for such purposes. If the dwelling, building, or structure is ordered removed or demolished by the magistrate court, it shall sell the materials of such dwellings, buildings, or structures and shall credit the proceeds of such sale against the cost of the removal or demolition and any balance remaining shall be deposited in the superior court by the code and ordinance enforcement officer, shall be secured in such manner as may be directed by the court, and shall be disbursed by the magistrate court to the persons found to be entitled thereto by final order or decree of the court.