data =  [ 
   "{\"date\":\"08/09/2019\",\"time\":\"15:56:55\",\"session\":0,\"part\":\"3\",\"slide\":\"sd-004-01\",\"feedback\":\"\"}",
   "{\"date\":\"08/09/2019\",\"time\":\"15:56:59\",\"session\":0,\"part\":1,\"slide\":\"sd-004-03\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"08/09/2019\",\"time\":\"15:57:03\",\"session\":0,\"part\":\"4\",\"slide\":\"sd-005-01\",\"feedback\":\"\"}",
   "{\"date\":\"08/09/2019\",\"time\":\"15:57:03\",\"session\":0,\"part\":1,\"slide\":\"sd-005-01\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"08/09/2019\",\"time\":\"15:57:04\",\"session\":0,\"part\":1,\"slide\":\"sd-005-01\",\"feedback\":\"\",\"page\":1}",
   "{\"date\":\"08/09/2019\",\"time\":\"15:57:05\",\"session\":0,\"part\":1,\"slide\":\"sd-005-01\",\"feedback\":\"\",\"page\":2}",
   "{\"date\":\"07/09/2019\",\"time\":\"22:02:54\",\"session\":0,\"part\":\"1\",\"slide\":\"sd-002-01\",\"feedback\":\"\"}",
   "{\"date\":\"07/09/2019\",\"time\":\"22:02:54\",\"session\":0,\"part\":1,\"slide\":\"sd-002-01\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"07/09/2019\",\"time\":\"22:02:56\",\"session\":0,\"part\":1,\"slide\":\"sd-002-02\",\"feedback\":\"\",\"page\":1}",
   "{\"date\":\"07/09/2019\",\"time\":\"22:02:57\",\"session\":0,\"part\":1,\"slide\":\"sd-002-02\",\"feedback\":\"\",\"page\":2}",
   "{\"date\":\"07/09/2019\",\"time\":\"22:02:59\",\"session\":0,\"part\":1,\"slide\":\"sd-002-02\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:56:35\",\"session\":0,\"part\":\"3\",\"slide\":\"sd-004-01\",\"feedback\":\"\"}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:56:35\",\"session\":0,\"part\":1,\"slide\":\"sd-004-01\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:56:37\",\"session\":0,\"part\":1,\"slide\":\"sd-004-03\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:56:40\",\"session\":0,\"part\":\"4\",\"slide\":\"sd-005-01\",\"feedback\":\"\"}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:56:40\",\"session\":0,\"part\":1,\"slide\":\"sd-005-01\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:56:42\",\"session\":0,\"part\":1,\"slide\":\"sd-005-01\",\"feedback\":\"\",\"page\":1}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:56:43\",\"session\":0,\"part\":1,\"slide\":\"sd-005-01\",\"feedback\":\"\",\"page\":2}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:52:49\",\"session\":0,\"part\":\"1\",\"slide\":\"sd-002-01\",\"feedback\":\"\"}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:52:49\",\"session\":0,\"part\":1,\"slide\":\"sd-002-01\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:52:55\",\"session\":0,\"part\":\"3\",\"slide\":\"sd-004-01\",\"feedback\":\"\"}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:52:55\",\"session\":0,\"part\":1,\"slide\":\"sd-004-01\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"07/09/2019\",\"time\":\"21:52:58\",\"session\":0,\"part\":1,\"slide\":\"sd-004-03\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"04/09/2019\",\"time\":\"14:11:45\",\"session\":0,\"part\":\"3\",\"slide\":\"sd-004-01\",\"feedback\":\"\"}",
   "{\"date\":\"04/09/2019\",\"time\":\"14:11:45\",\"session\":0,\"part\":1,\"slide\":\"sd-004-01\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"04/09/2019\",\"time\":\"14:11:45\",\"session\":0,\"part\":\"3\",\"slide\":\"sd-004-01\",\"feedback\":\"\"}",
   "{\"date\":\"04/09/2019\",\"time\":\"14:11:45\",\"session\":0,\"part\":1,\"slide\":\"sd-004-01\",\"feedback\":\"\",\"page\":0}",
   "{\"date\":\"04/09/2019\",\"time\":\"14:11:45\",\"session\":0,\"part\":\"3\",\"slide\":\"sd-004-01\",\"feedback\":\"\"}",
   "{\"date\":\"04/09/2019\",\"time\":\"14:11:45\",\"session\":0,\"part\":1,\"slide\":\"sd-004-01\",\"feedback\":\"\",\"page\":0}"
]

sortedArray = sortArray(data)

console.log(sortedArray)

function sortArray(data) {
  var newarr = []

  // convert

  for (i=0;i<data.length;i++) {
    obj = JSON.parse(data[i])
    ts = new Date(obj.date + " " + obj.time).getTime()
    page = ""
    if (obj.page >= 0) page = obj.page

    newarr.push(
      {
        "ts": ts,
        "date": obj.date,
        "time": obj.time,
        "session": obj.session,
        "slide": obj.slide,
        "feedback": obj.feedback,
        "page": page,
        "raw": data[i]
      }
    )
  }

  // sort asc

  newarr.sort((function (a, b) { 
    return new Date(a.ts) - new Date(b.ts) 
  }))

  // construct to the original json / data

  var a = []

  for (i=0;i<newarr.length;i++) {
    a.push(newarr[i].raw)
  }

  return a
}

Live code: https://playcode.io/452749

const { dialog } = require('electron')

function showMsg(s) {
  const options = {
    title: 'MedDay',
    message: s,
    //icon: 'src/icon.png',
  };

  dialog.showMessageBox(null, options)
}

showMsg("Hellow")
var fs = require('fs');
fs.readFile(app.getPath('desktop')+'/thefile.json', 'utf-8', (err, existingData) => {
  if(err){ }
  console.log("existingData: "+existingData);
})
var fs = require('fs');
try { 
  fs.writeFileSync(app.getPath('desktop')+'/thefile.txt', content, 'utf-8'); 
}
catch(e) { alert('Failed to save the file !'); }
function ConvertToCSV(objArray) {
  var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
  var str = '';

  for (var i = 0; i &lt; array.length; i++) {
      var line = '';
      for (var index in array[i]) {
          if (line != '') line += ','

          line += array[i][index];
      }

      str += line + '\r\n';
  }

  return str;
}
mainWindow.webContents.executeJavaScript('localStorage.getItem("key");', true)
.then((result) =&gt; {
    console.log(result) 
})