mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { ObjectService } from './object.service';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class SortService {
|
|
|
|
constructor(private ObjectService: ObjectService) { }
|
|
|
|
sortArrayISODate(myArray: any) {
|
|
if(myArray.length > 0){
|
|
return myArray.sort(function (a, b) {
|
|
return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0);
|
|
});
|
|
}
|
|
}
|
|
|
|
sortArrayByDate(myArray: any) {
|
|
console.log(myArray[0].taskStartDate);
|
|
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);
|
|
});
|
|
}
|
|
}
|
|
|
|
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()
|
|
|
|
})
|
|
|
|
}
|
|
}
|