Reading list of saved files returns the files in a random order

Can any one help, I’ve been stuck on this for days and days.

I generate and then save PDF files (in a specific order) to the tmpDirectory, then I read that list of files saved in this directory and merge those saved PDF files in to one new single PDF file (then delete the tmp files).

On Android when I read the list of files they are always listed in the same order that they were saved, so when merging those PDF files in to a new single PDF file, the page order is as required (the same order in which they were saved).

However the issue is on iPhone when I read the list of saved PDF files in the tmpDirectory, the list is in a random order and not in the same the order in which they were saved in, hence when merging the tmp PDF files in to a single PDF file the page order is all mixed up.

I have tried to get the lastModifedDate so I can reorder the file list so when I merge them they are in the correct order but without success, does any one have any examples to do this.

Native iOS built with Volt Builder.

Current Code:

function getFiles(path) {
    function (fileSystem) {
     var reader1 = fileSystem.createReader();
        function (entries) {
          console.log(JSON.stringify(entries)); // <== ios file entries are in a random order
          var urls = new Array; 
          var i; 
          var len = entries.length;
         // ?? Get lastModifiedDate and reorder files entries here before looping?? //

          for (i=0; i<len; i++) {
                  if (entries[i].isFile == true) {

  } );

I ended up getting the lastModified then passed that value along with the urls.push function and then re-orded the list in the next function.