TL:DR
I’ve tried and I can sort datetimes like “2019-05-23 08:50:00”
but my datetimes are like “2019-05-22T10:42:46.769Z”,
how do i order them? either when they come from the db (sqlite) or when they’re already in a list locally
Hey I created a test environment for myself to test this online with datetimes with the format ‘yyyy-MM-dd HH:mm:ss’ much like the iso format I use, and executed a query that you don’t really need to fully understand, just focus on the attempt to order the result by one of the datetimes and how it works
but that’s my test environment, now in my real app I deal with iso strings

Being able to select the times with ion-datetime

but it turns out when I do the process of adding or updating one of these iso strings into the database it doesn’t work in the format I expected it to, it comes with a sligh variation, here are some examples

So when in my code I execute the query that I always do
if u’re interested, its this one
let sql = 'SELECT * FROM Appointment INNER JOIN UtilizadorAppointment ON Appointment.id = UtilizadorAppointment.idAppointment WHERE UtilizadorAppointment.idUtilizador = ? AND date(Appointment.data) = ?';
but this time around I try to order it at the end
let sql = 'SELECT * FROM Appointment INNER JOIN UtilizadorAppointment ON Appointment.id = UtilizadorAppointment.idAppointment WHERE UtilizadorAppointment.idUtilizador = ? AND date(Appointment.data) = ? order by datetime(horaInicial) ASC';
it doesn’t work.
So I suppose it doesn’t work because of the slight variation in format, how do I counter this? Can I still somehow order these strings when they come from the db, or when I have them locally in a list?
edit:
I’ve tried using solutions like
var newArray = oldArray.sort(function(a,b){
if (a.date < b.date) return -1;
else if (a.date > b.date) return 1;
else return 0;
});
but they didn’t work