Currently I have an index column using this code:
<ng-container matColumnDef="id">
<mat-header-cell *matHeaderCellDef mat-sort-header>Id</mat-header-cell>
<mat-cell *matCellDef="let row; let i = index;">{{i}}</mat-cell>
</ng-container>
The problem with this code is that the numbers don't move when I sort by other columns. ie. It starts with all rows having descending indices but then if I sort by another row the index column stays the same while all other columns adjust.