import { PipeTransform , Injectable , Pipe } from '@angular/core' ; import { Request } from './request' ; import { Status } from './status' ; export class Consumer { constructor ( public error , public message , public status , public request ) { } } @ Pipe ( { name : 'consumerSort' , pure : false } ) @ Injectable ( ) export class ConsumerSortPipe implements PipeTransform { transform ( array ) { if ( array == null ) { return array ; } array . sort ( ( a , b ) => { a = a . status . group . replace ( /[_\W]/g , String . fromCharCode ( 0xFFFF ) ) ; b = b . status . group . replace ( /[_\W]/g , String . fromCharCode ( 0xFFFF ) ) ; if ( a . toLowerCase ( ) < b . toLowerCase ( ) ) { return - 1 ; } else if ( a . toLowerCase ( ) > b . toLowerCase ( ) ) { return 1 ; } else { return 0 ; } } ) ; return array ; } }