title: Does anyone knows why mat-sort won't work in this piece?
body: <p>I am using Angular to render a mat-table and mat-sort won't work. This is my code in HTML (ng-template used to render cells, but I quite sure that doesn't affect mat-sort):</p>
  <pre><code> &lt;table mat-table [dataSource]=&quot;dataSource&quot; matSort&gt;
      &lt;ng-container
        [matColumnDef]=&quot;column&quot;
        *ngFor=&quot;let column of displayedColumns&quot;
      &gt;
        &lt;th
          mat-header-cell
          mat-sort-header
          *matHeaderCellDef
        &gt;
          &lt;span&gt;
            {{ column }}
          &lt;/span&gt;
        &lt;/th&gt;
        &lt;td mat-cell *matCellDef=&quot;let element&quot;&gt;
          &lt;ng-container
            *ngTemplateOutlet=&quot;
              renderCell;
              context: { element: element, column: column }
            &quot;
          &gt;&lt;/ng-container&gt;
        &lt;/td&gt;
      &lt;/ng-container&gt;
  
      &lt;tr mat-header-row *matHeaderRowDef=&quot;displayedColumns; sticky: true&quot;&gt;&lt;/tr&gt;
      &lt;tr mat-row *matRowDef=&quot;let row; columns: displayedColumns&quot;&gt;&lt;/tr&gt;
    &lt;/table&gt;
  </code></pre>
  <p>And this is my .ts:</p>
  <pre><code> @ViewChild(MatSort, { static: false })
    public sort: MatSort;
  
    constructor(
    ) {}
  
    ngOnInit(): void {}
  
    ngAfterViewInit(): void {
        this.dataSource.paginator = this.paginator;
        this.dataSource.sort = this.sort;
      }
    }
  </code></pre>