title: Kotlin object expressions: Comparator example
body: <p>This code basically sorts the array in a descending order:</p>
  
  <pre><code>val arrayList = arrayListOf(1, 5, 2)
  
  Collections.sort(arrayList, object : Comparator&lt;Int&gt; {
     override fun compare(x : Int, y: Int) = y - x
  })
  </code></pre>
  
  <p>How in the world does overriding the compare method with <code>y - x</code> works? How does Kotlin know what <code>y - x</code> means to put <code>y</code> before <code>x</code> if <code>y &lt; x</code>?</p>