Пример js кода:
const newSortedData = newData .slice() .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() )