Files
doneit-web/src/app/services/functions/sort.service.ts
T

34 lines
1.0 KiB
TypeScript
Raw Normal View History

2021-10-18 13:58:26 +01:00
import { Injectable } from '@angular/core';
2021-11-23 16:23:44 +01:00
import { ObjectService } from './object.service';
2021-10-18 13:58:26 +01:00
@Injectable({
providedIn: 'root'
})
export class SortService {
2021-11-23 16:23:44 +01:00
constructor(private ObjectService: ObjectService) { }
2021-10-18 13:58:26 +01:00
sortArrayISODate(myArray: any) {
2021-10-19 09:18:02 +01:00
if(myArray.length > 0){
return myArray.sort(function (a, b) {
return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0);
});
}
2021-10-18 13:58:26 +01:00
}
2022-01-28 15:59:01 +01:00
2021-10-18 13:58:26 +01:00
sortArrayByDate(myArray: any) {
console.log(myArray[0].taskStartDate);
2021-10-19 09:18:02 +01:00
if(myArray.length > 0){
return myArray.sort(function (a, b) {
return (new Date(a.workflowInstanceDataFields.StartDate) < new Date(b.workflowInstanceDataFields.StartDate)) ? -1 : ((new Date(a.workflowInstanceDataFields.StartDate) > new Date(b.workflowInstanceDataFields.StartDate)) ? 1 : 0);
});
}
2021-10-18 13:58:26 +01:00
}
2021-11-23 16:23:44 +01:00
sortDate(array = [], path: string) {
return array.sort( (a,b)=> {
2022-01-28 15:59:01 +01:00
return new Date(this.ObjectService.deepFind(b, path)).getTime() - new Date(this.ObjectService.deepFind(a, path)).getTime()
2021-11-23 16:23:44 +01:00
})
}
2021-10-18 13:58:26 +01:00
}