I am running my code in AWS Lambda(Nodejs). have below code to sort my custom array of objects
let a = [];
let ob1= {"ts": "1582709708.009700"};
let ob2= {"ts": "1582709806.011000"};
let ob3= {"ts": "1582709782.010600"};
let ob4= {"ts": "1582709777.010400"};
let ob5= {"ts": "1582709791.010800"};
a.push(ob1);
a.push(ob2);
a.push(ob3);
a.push(ob4);
a.push(ob5);
a.sort((m1, m2) => {
let m1Ts = moment.unix(m1.ts).utc();
let m2Ts = moment.unix(m2.ts).utc();
return m1Ts.isAfter(m2Ts);
});
the above code returns below result with a runtime of 12.x
[{"ts":"1582709708.009700"},{"ts":"1582709806.011000"},{"ts":"1582709782.010600"},{"ts":"1582709777.010400"},{"ts":"1582709791.010800"}]
and for a runtime of 10.x
[{"ts":"1582709708.009700"},{"ts":"1582709777.010400"},{"ts":"1582709782.010600"},{"ts":"1582709791.010800"},{"ts":"1582709806.011000"}]
The same code gives different results for the sort. Any suggestions?