title: ERROR TypeError: Cannot read property 'filter' of undefined. How do I fix this?
body: <p>I am using custom filter to create the sort order from  but least first followed by next but getting error <code>&quot;ERROR TypeError: Cannot read property 'filter' of undefined&quot;</code>.</p>
  <p>Please help me to fix as it's not allowing to render anything on page.</p>
  <p>What changes do I need to make to fix this? Any help is appreciated.</p>
  <p>table-filter.pipe.ts</p>
  <pre><code>import { Pipe, PipeTransform } from &quot;@angular/core&quot;;
  
  @Pipe({
    name: &quot;tableFilter&quot;
  })
  export class TableFilterPipe implements PipeTransform {
    transform(list: any[], filters: any) {
      //console.log(&quot;table-filter&quot;, list);
      const keys = Object.keys(filters).filter(key =&gt; filters[key]);
      const filterUser = (user: { [x: string]: any }) =&gt;
        keys.every(key =&gt; {
          if (key == &quot;sdob&quot;) {
            return (
              new Date(user[&quot;dob&quot;]) &gt;=
              new Date(new Date(filters[key]).setHours(0, 0, 0, 0))
            );
          } else if (key == &quot;edob&quot;) {
            return (
              new Date(new Date(filters[key]).setHours(0, 0, 0, 0)) &gt;=
              new Date(user[&quot;dob&quot;])
            );
          } else if (
            key === &quot;dl&quot; &amp;&amp;
            user[&quot;assigned_to&quot;].filter((e: { dl: any }) =&gt; e.dl === filters[key])
              .length
          ) {
            return user;
          } else if (key === &quot;score&quot;) {
            const low = filters[key] === &quot;20&quot; &amp;&amp; user[&quot;score&quot;] &lt;= filters[key];
            const medium =
              filters[key] === &quot;50&quot; &amp;&amp; user[&quot;score&quot;] &lt; 50 &amp;&amp; user[&quot;score&quot;] &gt;= 21;
            const high =
              filters[key] === &quot;70&quot; &amp;&amp; user[&quot;score&quot;] &lt; 70 &amp;&amp; user[&quot;score&quot;] &gt;= 51;
            const veryHigh = filters[key] === &quot;71&quot; &amp;&amp; user[&quot;score&quot;] &gt;= 71;
            if (low || medium || high || veryHigh) {
              return user[key];
            }
          } else {
            return user[key] === filters[key];
          }
      });    
  
      if(list) {
        let filterList = list.filter(filterUser);
        list.sort((lhs, rhs) =&gt;this.lowestScore(lhs.assigned_to) - this.lowestScore(rhs.assigned_to));
      }
      //console.log(filterList, list);
  
      return keys.length ? list.filter(filterUser) : list;
    }
    
    lowestScore(assign: any) {
      //console.log(&quot;assign &quot;, assign);
      let filterData = assign.filter(item =&gt; Number(item.co_score));
      let leastScrore = Math.min(...filterData.map(item =&gt; item.co_score));
      //console.log(&quot;least &quot;, leastScrore);
      return leastScrore;
    }
  }
  </code></pre>