How does RMMV determine the z-index of pictures?

It doesn't appear to be based on the order of ID numbers, as picture #1 is in front of picture #2, but picture #3 is in front of picture #1. It also doesn't appear to be based on the ID numbers of the events that show the pictures, nor the chronological order of when I created those events.

Thanks!
For me the higher ID is always above lower ID's regardless of when they're added or what order; have you tried in a project with no plugins? Maybe you have one that alters this functionality in some way.
Thanks, Galenmereth. That was indeed the problem. It was Yanfly's Picture Common Events that was doing it.

Original thread: https://forums.rpgmakerweb.com/threads/how-does-rmmv-determine-the-z-index-of-pictures.109335/