I know what you mean, but I don't think there's a problem it this case. I want to be able to provide links to the previous and next pictures starting from a certain 'current' picture in a photo gallery. The idea is that when someone clicks on a thumbnail, they can choose prev/next to move through the pictures without returning to the thumbnails.
Most unix systems give the files by default in order they were created or by the sequence of links in fats, I think. The exact position isn't so important, as long as it's consistent within the html session. Which it should be, unless files are updated or moved while somebody is watching them.
I could sort them alphabetically or so, but I don't really see the point of doing that. It's really not that important.