This commit is contained in:
tiago.kayaya
2022-01-28 17:34:27 +01:00
parent 666a51e710
commit 202e09231b
4 changed files with 29 additions and 16 deletions
+2 -2
View File
@@ -8,11 +8,11 @@ export class ObjectService {
constructor() { }
deepFind(obj, path) {
deepFind(obj, path):any {
var paths = path.split('.')
, current = obj
, i;
for (i = 0; i < paths.length; ++i) {
if (current[paths[i]] == undefined) {
return undefined;
+5 -1
View File
@@ -27,7 +27,11 @@ export class SortService {
sortDate(array = [], path: string) {
return array.sort( (a,b)=> {
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();
})
}
}