Why the iterator won't sort for you
DriveApp.getFolderById(id).getFiles() hands back a FileIterator, not an array. The order it returns files is determined by Drive's internal indexing, and there's no sort parameter you can pass to change it. Calling hasNext() and next() in a loop gives you whatever sequence Drive feels like that day — usually insertion order, sometimes not.
The fix is straightforward: drain the iterator into a plain JavaScript array, then use Array.sort() with a comparator. Date objects in Apps Script subtract cleanly (dateA - dateB returns a number), so the comparator is one line.