When the retained percentage is insufficient to pay all claims for labor or materials, the court shall, in making distribution under section 573.18, order the claims in each class paid in the order of filing the same.