I need to iterate through a potentially very large directory (arbitrarily large). From what I understand, the regular glob.glob function stores a list of all the matching filenames in memory, but the glob.iglob function uses an iterator. So using the regular glob.glob function is out of the question, since there may be A lot of files in the directory.

My problem is that iglob iterates through the directory in a seemingly random order. I would like it to iterate through the files in alphabetical order. I cannot get a list of all the filenames at once, and just sort them, so I am wondering if there is a way to make iglob iterate through the directory in alphabetical order.

Edit
Report