I have this piece of code for sorting:
compareDates(a: string, b: string, isAsc: boolean) {
// splitting the string after on dot, because the date string is like: 14.06.2022
var d1Splitted = a.split('.');
var d2Splitted = b.split('.');
const d1 = Date.parse(d1Splitted[2] + '-' + d1Splitted[1] + '-' + d1Splitted[0]);
const d2 = Date.parse(d2Splitted[2] + '-' + d2Splitted[1] + '-' + d2Splitted[0]);
return isAsc ? Number(d1) - Number(d2) : Number(d2) - Number(d1);
}
wenn I sort a list by date I get the well sorted list, but after few times of clicking on sort button I get this:
