title: Java 8 Lambda: Comparator
body: <p>I want to sort a list with Lambda:</p>
  
  <pre><code>List&lt;Message&gt; messagesByDeviceType = new ArrayList&lt;Message&gt;();      
  messagesByDeviceType.sort((Message o1, Message o2)-&gt;o1.getTime()-o2.getTime());
  </code></pre>
  
  <p>But I got this compilation error:</p>
  
  <pre><code> Multiple markers at this line
      - Type mismatch: cannot convert from long to int
      - The method sort(Comparator&lt;? super Message&gt;) in the type List&lt;Message&gt; is not applicable for the arguments ((Message o1, Message o2) 
       -&gt; {})
  </code></pre>