Suppose there are 3 files (abc.jpg, test.bmp and xyz.png) in SD card. When I use the f_readdir function, I understood that it does not retrieve the files in alphabetical order. So in which sequence it is retrieving the file name? Please share your ideas.
random is a good idea. it's also wrong.
it is highly likely that it will be based upon the order in which they are encountered in the directory structure on the card. and that will probably depend upon the order in which they are written to the card in the first place.
As far as your application is concerned, the order is undefined. This means that, if the order is important to your application, then it is up to your application to perform the require sorting/ordering.
In practice, the order probably depends on the order in which the entries actually appear on the physical medium. That will depend upon the lifetime history of the card...