Whenever any party to an action who holds a lien upon the property, or any part thereof, has other security for the payment of the amount of such lien, the court in its discretion may order such security to be exhausted before distribution of the proceeds of sale, or may order a just deduction to be made from the amount of the lien on the property on account thereof.
N.D.C.C. § 32-16-21