title: Custom sorting pipe for Angular 6
body: <p>I am trying to sort my data in the ngFor loop , but my custom pipe doesnot work as intened , can anybody help me out...</p>
  
  <pre><code>  export class OrderbyLastMessagePipe implements PipeTransform {
  
    transform(array: Array&lt;string&gt;, args?: any): Array&lt;string&gt; {
  
      if (array !== undefined &amp;&amp; array !== null &amp;&amp; args !== '') {
  
        console.log('args', array);
  
          const direction = args === 'desc' ? 1 : -1;
          array.sort((a: any, b: any) =&gt; {
  
            console.log('args', a);
  
            if (a['lastUpdatedat'] &lt; b['lastUpdatedat']) {
                  return -1 * direction;
              } else if (a['lastUpdatedat'] &gt; b['lastUpdatedat']) {
                  return 1 * direction;
              } else {
                  return 0;
              }
          });
      }
      return array;
  }
  </code></pre>
  
  <p>My Component ng container is this , i am using two filters one for search and another for sort on specific lastupdatedat value which is the timestamp ...</p>
  
  <pre><code> &lt;ng-container *ngFor="let User of uLists | orderbyLastMessage:'uLists':true"&gt;         
  </code></pre>