When two or more persons apply to the sheriff to redeem at the same time, the sheriff shall allow the person having the prior lien to redeem first, and so on. The sheriff shall immediately pay the money over to the person from whom the property is redeemed, if that person is present at time of redemption; or if not, at any time thereafter when demanded. When a sheriff wrongfully refuses to allow any person to redeem, the right to redeem shall not be prejudiced by such refusal, and the sheriff may be required, by order of the court, to allow such redemption.