If the dates are being stored as strings then sorting them as strings is going to be alphabetizing them by the short day. If you convert them to Date objects before sorting it should work:
loaddata() {
this.$db.DBData.find({}).exec((err, docs) => {
let newDocs = docs.map((doc)=>{
doc.pubDate = new Date(doc.puDate).valueOf();
});
newDocs.sort((a, b)=>{
return a.pubDate - b.pubDate; //you may have to switch the order
});
this.Data = newDocs;
});
}
Another solution would be to save the Date value instead of the string representation. For example the dates you gave above translate to:
[1530296100000, 1529893320000, 1530241800000, 1530394543000]
Then sorting them results in:
[1529893320000, 1530241800000, 1530296100000, 1530394543000]
Converted back that's:
["Sun Jun 24 2018 22:22:00 GMT-0400 (Eastern Daylight Time)",
"Thu Jun 28 2018 23:10:00 GMT-0400 (Eastern Daylight Time)",
"Fri Jun 29 2018 14:15:00 GMT-0400 (Eastern Daylight Time)",
"Sat Jun 30 2018 17:35:43 GMT-0400 (Eastern Daylight Time)"]
You can see how they are sorted in order now and back in their string representation. Sorry for the time zone conversion I ran this example in the console on my browser to make sure it works.