Try:
I have to guess why this happend in your example. I would say in your example the for each uses the UID/IID of the sprites so is the direct opposite to your ID counting. So you it has to go through all your sprites to get the on with the correct ID and you have to click for every sprite to move on place.
If you want to move the sprites backwards you have only to change your count back to 5 and to subtract and the for each to decending.