Sort the files before iterating over them.