I'm doing a website with a gallery of images. No widgets, just images placed on a grid and a pop-up displays a zoomed when clicked on.
The zoomed image controls allow you to click "next" and "previous" but they don't display in the order as shown on the page.
If ImageG is next to ImageA, how to I ensure that is the same order when clicking the next and previous buttons?
After all this time I thought I knew this stuff.
I was wrong.
Any help gratefully received.

PS. I have three variants of the website and the order isn't necessarily the same in each variant.