JavaScript Sorts berdasarkan ID
elems.sort((a, b) => a.id - b.id);
Easy Echidna
elems.sort((a, b) => a.id - b.id);
function sortByDate( a, b ) {
if ( a.created_at < b.created_at ){
return -1;
}
if ( a.created_at > b.created_at ){
return 1;
}
return 0;
}
myDates.sort(sortByDate);//myDates is not sorted.