When there are liens by judgment or otherwise, on the interest of any party to a partition suit, the court may, on the petition of any person holding a lien, ascertain the liens and apply the dividend of such party in the proceeds of sale to the discharge of such liens so far as may be necessary for that purpose.