The proceeds of the sale of the property shall be applied under the direction of the court as follows:
- (1) to pay its just proportion of the general costs of the action;
- (2) to pay the costs of the referee;
- (3) to pay all legal fees and costs awarded under section 558A.19;
- (4) to satisfy and cancel of record, pursuant to section 558A.18, the several liens, if any, in their order of priority, by payment of the sums due and to become due; the amount remaining due as proven to the court;
- (5) the residue among the owners of the property sold, according to their respective shares.