I would use the index which we can get within matCellDef binding:
*matCellDef="let row; let index = index" [formGroupName]="index"
Forked Stackblitz
For solving problems with sorting and filtering take a look at this answer Angular Material Table Sorting with reactive formarray