mp-common
Version:
This is XPO MarketPlace common libary
24 lines (20 loc) • 494 B
text/typescript
import { Pipe, PipeTransform } from '@angular/core';
({
name: 'orderByProperty'
})
export class OrderByPropertyPipe implements PipeTransform {
transform(list: any[], property: string): any {
if (list) {
list.sort((a, b) => {
if (a[ property ] < b[ property ]) {
return -1;
} else if (a[ property ] > b[ property ]) {
return 1;
} else {
return 0;
}
});
}
return list;
}
}