2
i am developing an application in Engineering which receives the following object from an API:
pessoas = [
{ nome: 'Lucas', data: '2010-Fev-04'},
{ nome: 'Felipe', data: '1994-Dec-10'},
{ nome: 'Ana', data: '1994-Jun-21'},
{ nome: 'Carlos', data: '1991-Fev-20'}
];
I need to sort the column by date, but it comes in string form from the API. I can’t see a way to sort the dates correctly since I have no way to change the content of this object and make the date a timestamp.
From the moment you receive this object from the API, it is only a copy of the original data and could be manipulated in your Angular application. I didn’t understand the restriction you put, could give more context?
– Marcell Alves
Hi Marcel. The problem is that with the date in the form of a string, the ordering will not take place in a temporal way. For example, 1994-Dec-10 would be less than 1994-Jun-21. I thought of creating a second object from the first, using the new Date to change the format, but as the size of the object may vary, I don’t know if this would be the best option
– Marcos Penha