Upon the presentation of the petition with due proof of the service of the notice of the application, the court shall ascertain the amount due to the petitioner and to each other person whose claim is a lien upon the surplus money and the priorities of the several liens. The court thereupon shall make such order for the distribution of the surplus money as justice requires, and the surplus money must be distributed accordingly.
N.D.C.C. § 35-22-25