import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'orderbydata'
  //pure: false
})
export class OrderbyDataPipe implements PipeTransform {

    transform(records: Array<any>, args?: any): any {
       //console.log("order by data ",records ,args); 
        return records.sort(function(a, b){
              if(a[args.property] < b[args.property]){
                return -1 * args.direction;
              }
              else if( a[args.property] > b[args.property]){
                return 1 * args.direction;
              }
              else{
                return 0;
              }
            });
        };
 

}
