I set up pipeline for sorting. It is sorting but I got this type of error:
cannot read properties of undefined (reading 'sort')
in angular core.js in my local running.
Here is my order-by.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'orderBy',
})
export class OrderByPipe implements PipeTransform {
transform(array: any, field: string): any[] {
array.sort((a: any, b: any) => {
if (a[field] < b[field]) {
return -1;
} else if (a[field] > b[field]) {
return 1;
} else {
return 0;
}
});
return array;
}
}