title: Min / max function of two Comparables
body: <p>I need to find the smaller of two <code>Comparable</code> values:</p>
  <pre><code>Comparable&lt;C&gt; a = ...;
  Comparable&lt;C&gt; b = ...;
  Comparable&lt;C&gt; min = a.compareTo(b) &lt;= 0 ? a : b;
  </code></pre>
  <p>This is similar to <code>Math.min(a, b)</code>, but for <code>Comparable</code>.</p>
  <p>I know that the ternary operator is already quite short, but I can't inline the expressions for <code>a</code> and <code>b</code> and I think that <code>min(a, b)</code> and <code>max(a, b)</code> is easier to understand.</p>
  <p>I know that there are several functions that operate on <code>Stream</code> and <code>Collection</code> values, like:</p>
  <pre><code>Stream.of(a, b).min(Comparator.naturalOrder())
  </code></pre>
  <p>This would help to inline the expressions, but I still find it difficult to read and a bit too much overhead for such a small task.</p>
  <p>For the moment I'm using my own utility function, but I'm interested to know if there's an existing function for this purpose.  How can one find the minimum of two <code>Comparable</code> values in a readable and library-independent manner without too much performance overhead?</p>