in reply to Re^2: Optimize file renaming.
in thread Optimize file renaming.

In any case this is a good occasion to remind that readdir returns the filenames in whatever order they're stored in the filesystem.