Hi, nice article!
To avoid to call setTimeout() function inside your ngOnInit() method, you can to use the ngAfterViewInit() method.
ngAfterViewInit() {
this.dataSource.sort = this.sort;
this.dataSource.sortingDataAccessor = (item, property) => {
return item[property].toLocaleLowerCase();
};
}
According to documentation, Angular guarantees that your @ViewChild will be set before ngAfterViewInit() is called.