title: Rxjs use min operator on array property
body: <p>I understand we can use the min operator on an array of numbers. But how would i use it on an array of objects, with a number property?</p>
  
  <pre><code>var source = Rx.Observable.fromArray([1,3,5,7,9,2,4,6,8]).min();
  </code></pre>
  
  <p>This is how the docs describe it. This will emit <code>1</code>. How do i do this...</p>
  
  <pre><code>var source = Rx.Observable.fromArray([{a: 1, b:"first"},{a: 3, b:"second"},{a: 5, b:"third"}]).min();
  </code></pre>
  
  <p>I want to use <code>min</code> by the inner property values. So, compare the values of <code>a</code> in each object in the array and emit that object.</p>
  
  <p>I understand min takes a compare function, but i don't know if it can be used here. </p>
  
  <p>I also want it to emit the object, not the minimum property value.</p>
  
  <p>Edit:</p>
  
  <p>So, i'm using Ngrx in an Angular 4 app and trying to use the <code>min</code> operator on a <code>store.select</code> Observable. For some reasong, the below code, where i first subscribe and then create another observable from the response and then use the min works, but if i skip the subscribe and try to use the min operator like the lower code, it fails and emits the complete array of ClientFacilities.</p>
  
  <p>Anybody know what's going on? Aren't they both the same thing?</p>
  
  <p>This works:</p>
  
  <pre><code>this.store.select(fromRoot.getClientFacilitiesArray).take(1).subscribe(res =&gt; {
                      Observable.from(res).min&lt;ClientFacility&gt;((a, b) =&gt; a.leaders_assigned - b.leaders_assigned)
                          .subscribe(res =&gt; console.log(res));
                  })
  </code></pre>
  
  <p>This fails:</p>
  
  <pre><code>this.store.select(fromRoot.getClientFacilitiesArray).take(1)
  .min&lt;ClientFacility&gt;((a, b) =&gt; a.leaders_assigned - b.leaders_assigned)
                          .subscribe(res =&gt; console.log(res));
  </code></pre>