import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class CommonfunctionService { constructor() { } sortByProperty(property, order = 'asc'){ return function(a,b){ if (order == 'asc') { if(a[property] > b[property]) return 1; else if(a[property] < b[property]) return -1; return 0; } else { if(a[property] < b[property]) return 1; else if(a[property] > b[property]) return -1; return 0; } } } }