import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'sortByApha' }) export class SortAlphaPipe implements PipeTransform { transform(arr: Array<any>, prop: any, reverse: boolean = false) : any { if (arr === undefined) return; const m = reverse ? -1 : 1; return arr.sort((a: any, b: any): number => { const x = a[prop].toLowerCase(); const y = b[prop].toLowerCase(); return (x === y) ? 0 : (x < y) ? -1*m : 1*m; }); } }