Hi.
Basically what you should do is put all those .JPG files
into one new array, say $alljpg = array();
Regarding time when a file was created/last changed
you have this function [man]filemtime[/man]
int = filemtime( $filename )
Where the returned filemtime (probably file-modification-time)
is one integer, Unix timestamp, just like [man]time/man
This means you should be able to sort $alljpg by the [man]filemtime[/man] value.
It might not be easy for you to make all this.
But I am sure some nice helper can guide you with a bit of code.
Regards 🙂