angular-test/src/app/sort.ts

16 lines
402 B
TypeScript

// This is a simple encapsulation class for the Collator used in sorting.
export class Sort {
private collator = new Intl.Collator('et', {
numeric: true,
sensitivity: 'base',
});
constructor() { }
public sort(value: Array<any>, property: string, order: number, type = ''): Array<any> {
return value.sort((a, b) => this.collator.compare(a[property], b[property]) * order);
}
}