title: Comparing Nodes with Collections.sort
body: <p>I got a List with some Tree nodes and want to sort it. As the comparator I use a double variable owned by every node in the List.</p>
  
  <p>Thats my code:</p>
  
  <pre><code>List&lt;TreeNode&lt;String&gt;&gt; list = inputNode.getChildren();
  
  for(TreeNode&lt;String&gt; childNode : list)
     {
      Collections.sort(list, childNode.costs);
     }
  </code></pre>
  
  <p>TreeNode is defined like this:</p>
  
  <pre><code>public class TreeNode&lt;T&gt; {
  
  public T data;
  public double costs;
  public List&lt;TreeNode&lt;T&gt;&gt; children;
  
  // Bunch of getters and setters
  }
  </code></pre>
  
  <p>What I am try to do is, to sort(descending order) the List of child nodes. I dont want write something new thats already there. So why cant I use <code>Collections.sort</code>?</p>
  
  <p><a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#sort%28java.util.List,%20java.util.Comparator%29" rel="nofollow">Collections.sort</a> Isn't <code>double</code> a comparable datatype?</p>