title: Implement a comparable using objects hash codes
body: <p>I have a general method that needs to sort and search for generic objects,</p>
  
  <p><strong>Old Version</strong>: </p>
  
  <pre><code>    public &lt;T&gt; int isIn(T[] list, T t) {
  
         Arrays.sort(list, Comparator.comparingInt(Object::hashCode));  
   return Arrays.binarySearch(values,updatedObject.hashCode())
  
      }
  </code></pre>
  
  <p><strong>New Version:</strong></p>
  
  <pre><code>    public &lt;T&gt; int isIn(T[] list, T t) {
  
         Arrays.sort(list, Comparator.comparingInt(Object::hashCode));  
   return Arrays.binarySearch(values,updatedObject.hashCode(),Comparator.comparingInt(Object::hashCode))
  
      }
  </code></pre>
  
  <p>Assuming that hashcode() is implemented properly, I can't think of any case where this could fail or give any error. 
  What are the cases, if any, that this could give us an error ! </p>
  
  <p>NOTE: Code is edited, I added Comparator to the binary search</p>