I'm confused why the console is showing me a sorted array at both logs. Because at the first point where I'm logging it shouldn't be sorted?
static reloadAndSortItems() {
let array = [];
const items = Store.getStoredItems();
items.forEach(function (item) {
// getting the stored date --> back to date object
let episodeDate = Date.parse(item.episode);
let parsedEpisode = new Date(episodeDate);
array.push(parsedEpisode);
});
**// should not sorted at this point
console.log('not sorted', array);**
let tested = array.sort(function (a, b) {
return a - b
});
**// should be sorted array at this point
console.log('sorted', tested);**
}
this is the array that is coming in ( which is out of order) :
["2018-09-13T00:30:00.000Z","2018-09-14T05:25:00.000Z","2018-09-13T00:30:00.000Z","2018-09-11T01:30:00.000Z","2018-09-11T01:30:00.000Z"]