1 import { Pipe, PipeTransform } from '@angular/core';
2 import * as _ from 'lodash';
3 @Pipe({ name: 'orderBy' })
4 export class OrderByPipe implements PipeTransform {
6 transform(records: any[], args: any = {}): any {
7 args.direction = !_.isNil(args.direction) ? args.direction : 1;
10 return records.sort(function(a, b){
12 if(a[args.property] < b[args.property]){
13 return -1 * args.direction;
15 else if( a[args.property] > b[args.property]){
16 return 1 * args.direction;
23 return -1 * args.direction;
26 return 1 * args.direction;