What's the kind of logic that I have to use for sort my elements?
Here I generate all of the columns and rows.
dynamic-table.component.html
  <table>
    <tr>
      <th *ngFor="let col of columns" (click)="onClickSort()">{{col}}</th>
    </tr>
    <tr *ngFor="let user of users">
      <td *ngFor="let col of columns">{{user[col]}}</td>
    </tr>
  </table>
dynamic-table.component.ts
import {Component, Input, OnInit } from '@angular/core';
@Component({
  selector: 'app-dynamic-table',
  templateUrl: './dynamic-table.component.html',
  styleUrls: ['./dynamic-table.component.css']
})
export class DynamicTableComponent implements OnInit {
  @Input()
  users = [];
  @Input()
  columns: string[];
  constructor() {
  }
  onClickSort() {
    //ADD LOGIC SORT
  }
  ngOnInit() {
  }
}
My datas are in a mock.ts, I can find them in my service.
app.component.ts
import {Component, OnInit } from '@angular/core';
import {TableService} from './table.service';
@Component({
  selector: 'app-root',
  styleUrls: ['./app.component.css'],
  templateUrl: './app.component.html',
})
export class AppComponent implements OnInit {
  users;
  columns;
  constructor(private atService: TableService) {
  }
  ngOnInit(): void {
    this.columns = this.atService.getColumns();
    this.atService.getUsers().subscribe((res) => this.users = res);
  }
}
 
     
     
    