johnlewissims when two elements have the same priority (hard-coded by the extension), the order the extensions are enabled in are used.
If you disable and re-enable the GIF extension it will move to the end if it has the same priority as the emoji and mentions extensions.
If elements have a different priority, then that priority is used to order them. An extension or fork is required to change the order. I developed a prototype extension to change priorities of other extensions in the past but it's never been made into a stable extension.