Java: Sort an ArrayList based on an object field
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1814095/sorting-an-arraylist-of-contacts">Sorting an ArrayList of Contacts</a>  </p>
</blockquote>



<p>I am storing <code>DataNode</code> objects in an <code>ArrayList</code>. The <code>DataNode</code> class has an integer field called <code>degree</code>.
I want to retrieve <code>DataNode</code> objects from nodeList in the increasing order of <code>degree</code>. How can I do it.</p>

<pre><code>List&lt;DataNode&gt; nodeList = new ArrayList&lt;DataNode&gt;();
</code></pre>
