I use reflector to keep my pacman mirrors ordered by speed from me. However, when the mirrorlist is updated by pacman -Syu, I had do a sequence of commands to reflectorise it.
To automate it, add the following file:
./etc/pacman.d/hooks/mirrorupgrade.hook
[Trigger]
Operation = Upgrade
Type = Package
Target = pacman-mirrorlist
[Action]
Description = Updating pacman-mirrorlist with reflector and removing pacnew...
When = PostTransaction
Depends = reflector
Exec = /usr/bin/bash -c "reflector --sort rate --save /etc/pacman.d/mirrorlist && [[ -f /etc/pacman.d/mirrorlist.pacnew ]] && rm /etc/pacman.d/mirrorlist.pacnew"After this whenever a new pacman mirrorlist.pacnew is created via upgrade, it will automatically sort the mirrorlist entries by speed.