title: Filter array for multiple values and limit the result
body: <p>I have an array with multiple objects:</p>
  
  <pre><code>export class Task {
    id: number;
    title: string;
    state: number;
    priority: number;
    desc: string;
    date: string;
    listid: string;
  }
  </code></pre>
  
  <p><strong>How can I filter this array for the first five tasks with the closest upcoming dates?</strong> Furthermore, there's the possibility that an object's date is empty - <strong>in case there aren't at least five tasks with dates</strong>, the remaining amount of tasks shall be replaced with tasks sorted by their priority (5 high - 1 low).</p>
  
  <p>F.e. for the following array (I ignored the less important values) ..</p>
  
  <pre><code>tasks = [
    { date: 19-07-2019, priority: 2 },
    { date: 21-07-2019, priority: 3 },
    { date: 20-07-2019, priority: 4 },
    { date: null, priority: 2 },
    { date: null, priority: 4 },
    { date: null, priority: 5 },
    { date: null, priority: 3 }
    ];
  </code></pre>
  
  <p><strong>.. I want the function to return this:</strong></p>
  
  <pre><code>result = [
    { date: 19-07-2019, priority: 2 },
    { date: 20-07-2019, priority: 4 },
    { date: 21-07-2019, priority: 3 },
    { date: null, priority: 5 },
    { date: null, priority: 4 },
  ];
  </code></pre>
  
  <p>I've already tried figure a way out, but that's all I've got:</p>
  
  <pre><code>getFirstFiveTasks(): Observable&lt;Task[]&gt; {
      return of(this.tasks.filter(tasks =&gt; tasks.date &gt; this.date));
  }
  </code></pre>
  
  <p>But this one solely returns the tasks with upcoming date, doesn't limit the result to 5 and ignores the priority in case there would be tasks without dates.</p>