I have a set of data displaying. here the dates are not arranged in order.I want the data to be arranged in the descending order based on the dates.
HTML:
<mat-tab label="Active">
  <mat-icon for="search">search</mat-icon>
  <input type="search" [(ngModel)]="filter" name="search" class="search" placeholder="Company">
  <ul>
    <li *ngFor="let message of activeMessages| messagefilter: filter" (click)="showMessage(message)" [class.activeShow]="message.id == message_id">
      <span>{{message.messages[message.messages.length -1].updated_at  | date:'dd.MM.yyyy'}}</span>
      <img style="width: 40px;" [src]="message.from_user_image || '../assets/images/msg.png'"/>
      <p style="padding-top: 16px;display: inline;">{{message.from_user_name}}</p>
      <p style="padding-top: 10px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><b>{{message.messages[message.messages.length -1].text}}</b></p>
    </li>
  </ul>
</mat-tab>
TS:
loadMessages() {
    this.service
          .getMessages()
          .subscribe(
            data => {
              this.messagesdata = data;
              this.activeMessages = data.filter(msg => msg.active == true && msg.from_user_name !== 'Anonymus' && msg.messages.length > 0)
              this.closedMessages = data.filter(msg => msg.active == false && msg.from_user_name !== 'Anonymus' && msg.messages.length > 0);
            },error => {});
  }
here the date i am fetching is from messages array inside the data. So, can anyone help me to fix this issue

 
    