If all or any part of the land or buildings against which a mechanic’s lien has been established pursuant to this subtitle shall be sold under foreclosure or a judgment, execution or any other court order, all liens and encumbrances on such property shall be satisfied in accordance with their priority, subject to the limitation in the next sentence of this section. If the proceeds of the sale are insufficient to satisfy all liens established pursuant to this subtitle, then all proceeds available to satisfy each such lien shall be stated by the court auditor as one fund, and the amount to be disbursed to satisfy each lien established pursuant to this subtitle shall bear the same proportion to that fund as the amount of such lien bears to the total amount secured by all such liens, without regard to priority among such liens.