I’m not sure if the sorting makes the trouble, but as you can see you would have to prepend zeros to the file names in case you want the sorting to be executed as:
000.jpg
001.jpg
002.jpg
...
010.jpg
011.jpg
...
020.jpg
...