When any sheriff or other officer shall sell any property under execution or other process, or under any decree, judgment, or order of any court, it shall be his duty to ascertain what taxes are a lien upon such property and, upon a sale thereof, to first apply the proceeds of such sale to the payment of such taxes.