This commit is contained in:
tiago.kayaya
2022-01-28 19:06:09 +01:00
4 changed files with 80 additions and 55 deletions
+10 -4
View File
@@ -26,12 +26,18 @@ export class SortService {
}
sortDate(array = [], path: string) {
return array.sort( (a,b)=> {
console.log("AAA"+new Date(this.ObjectService.deepFind(a, path)));
console.log("BB"+new Date(this.ObjectService.deepFind(b, path)));
//return (new Date(this.ObjectService.deepFind(a, path)) < new Date(this.ObjectService.deepFind(b, path))) ? -1 : ((new Date(this.ObjectService.deepFind(a, path)) > new Date(this.ObjectService.deepFind(b, path))) ? 1 : 0);
return new Date(this.ObjectService.deepFind(b, path)).getTime() - new Date(this.ObjectService.deepFind(a, path)).getTime();
/* console.log("AAA"+new Date(this.ObjectService.deepFind(a, path)));
console.log("BB"+new Date(this.ObjectService.deepFind(b, path))); */
return (new Date(this.ObjectService.deepFind(a, path)) < new Date(this.ObjectService.deepFind(b, path))) ? -1 : ((new Date(this.ObjectService.deepFind(a, path)) > new Date(this.ObjectService.deepFind(b, path))) ? 1 : 0);
//return new Date(this.ObjectService.deepFind(b, path)).getTime() - new Date(this.ObjectService.deepFind(a, path)).getTime();
})
}
}