As you can see in the .ts file that I am trying to do the sorting the Array which is in Table Form. The Array is in Static
list.component.ts
sort(){
this.Homes.sort(function(a,b){
if(a>b)
return 1
if(a<b)
return -1
return 0;
});
}
list.component.html
<table class="table table-striped">
<thead>
<tr>
<th scope="col" (click)="sort()">Name</th>
<th scope="col">Age</th>
<th>Action</th>
</tr>
</thead>
<tbody *ngFor="let item of Homes">
<!-- <tr *ngIf="item.Age < 22"> -->
<tr>
<td scope="row">{{ item.Name }}</td>
<td class={{item.ColorClass}}>{{item.Age}}</td>
<td class="fa fa-trash" (click)="delete(item)"></td>
<td class="fa fa-pencil" (click)="edit(item)" data-toggle="modal" data-
target="#myModal"></td>
</tr>
</tbody>
</table>