The proceeds of the sale of the encumbered property shall be applied under the direction of the court as follows:
- (1) to pay its just proportion of the general cost of the action;
- (2) to pay the costs of the reference;
- (3) to satisfy the several liens in their order of priority by payment of the sums due and to become due;
- (4) the residue among the owners of the property sold according to their respective shares, as found by the court.