Java - Make a library class comparable
<p>Is it possible to make library classes comparable without extending them?</p>

<pre><code>import org.json.JSONObject;

LinkedList&lt;JSONObject&gt; list = getListFromFunction();

TreeSet&lt;JSONObject&gt; treeSet = new TreeSet&lt;JSONObject&gt;(list);
</code></pre>

<p>Making a <code>TreeSet</code> here is not possible as <code>JSONObject</code> is not comparable. How can I "attach" a custom comparator to <code>JSONObject</code>?<br> <em>(There is a unique property, say "_some_id" to compare with)</em></p>