title: need to sort, filter and set default value using rxjs
body: <p>I have an observable in angular application which is bound to the reactive forms dropdown control. I basically need to filter, sort and also show the default value. I have written two implementations where the the first one does the filtering and sorting but not the default value while the latter does the default value only. I am able to merge them together and get it to work but not sure if it is the best way. Can anybody give some insight into this please</p>
  <pre><code> this.nameList$ = this.nameService.getNames()
        .pipe(
          map(response =&gt; response
             .filter(t =&gt;
              t.name !== '!',
            )
            .sort(this.sortByNameAscending),
  
          ),
          takeUntil(this.destroy$)
        )
  
  
        this.nameList$ = this.nameService.getNames()
        .pipe(
          tap((values: any) =&gt; {
            const found = values.find(x =&gt; x.isDefault);
            if (found) {
              this.form.get('firstName').setValue(found.name);
            }
        
    
          })
         
          ,
          takeUntil(this.destroy$)
        )
  </code></pre>
  <p>I have tried this which works but not sure if it is the best way to do it</p>
  <pre><code> this.nameList$ = this.nameService.getTitles()
        .pipe(
          map(response =&gt; response
             .filter(t =&gt;
              t.name !== '!',
            )
            .sort(this.sortByNameAscending),
  
          ),
          takeUntil(this.destroy$)
        )
        .pipe(
          tap((response: any) =&gt; {
            const found = response.find(x =&gt; x.isDefault);
            if (found) {
              this.form.get('firstName').setValue(found.name);
            }
        
    
          })
         
          ,
          takeUntil(this.destroy$)
        )
  </code></pre>