title: How to pass a custom comparator to "sort"?
body: <p>Class <code>A</code> has the following comparator:</p>
  
  <pre><code>class A
    attr_accessor x
  
    def my_comparator(a)
      x**2 &lt;=&gt; (a.x)**2
    end
  end
  </code></pre>
  
  <p>I would like to use this comparator to sort an array where each item is of class A:</p>
  
  <pre><code>class B
    def my_method
      items.sort!(&lt;how can I pass my_comparator here ?&gt;)
    end
  end
  </code></pre>
  
  <p>How should I pass <code>my_comparator</code> to <code>sort!</code>?</p>