How to sort images in ImageFolder?

I have a trainset folder with different images:
They named like img0.jpg, img1.jpg ---- img990.jpg. But the problem is that they lie in a different order.
And when I use ImageFolder all this images loads in incorrect row.
So is it able to use some torch coustructions to sort this images or to load them in a right row without custom datasets?

The file names will be sorted in this line of code, so I don’t think it’ll be easy to change this and would recommend to either use a custom Dataset or to prepend zeros to the image indices.