For most normal cases, you don’t need to rerank your mirrors prior to updating. I rate my mirrors about twice per year.
That being said, if you want to, you can do so. A script like this would work:
# Update mirrors
rate-mirrors arch --max-delay 7200 | sudo tee /etc/pacman.d/mirrorlist
# Update system
yay
Make sure you install rate-mirrors with sudo pacman -S rate-mirrors before running the script for the first time.