order by date

This commit is contained in:
tiago.kayaya
2021-10-18 13:58:26 +01:00
parent ba2c3c3543
commit 8b29af8599
16 changed files with 131 additions and 97 deletions
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { SortService } from './sort.service';
describe('SortService', () => {
let service: SortService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(SortService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,21 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class SortService {
constructor() { }
sortArrayISODate(myArray: any) {
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);
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);
});
}
}