import {Pipe, PipeTransform} from 'angular2/core';
@Pipe({ name: 'orderBy' })
export class OrderrByPipe implements PipeTransform {
transform(records: Array<any>, args?: any): any {
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;
}
});
};
}
Please check this, it worked for me, but i see one thing in that, integer sorting suppose if we take 1,2,3,4,5,6,7,8,9,10,11,12,13. it is behaving wierd