Can I iterate through files using an iteration order other than latest modified time
07:58 13 Jun 2017

I am iterating through text files using Google Apps Script and the pasting contents of text files to a google sheet

var allFiles = sourceFolder.getFiles()
var file = allFiles.next()
var fileContent = file.getAs('text/plain').getDataAsString()
sheet = ss.getSheetByName("Data")
var pasteRange = sheet.getRange(rowId,205)
pasteRange.setValues(fileContent)

All is fine. The variable RowId is taken from the filename of the text file. The problem is that a user may create a text file for RowId 230 then 1 minute later another user may also create row 230. I need the latter user to take priority. But Google iterates through the files using most recent first leaving me with the oldest update to row 230 in the google sheet.

Is there any way of sorting the files in the file iterator to determine the iteration order. I can manipulate the filename if that helps.

google-apps-script google-drive-api iteration