title: Collections.sort isn't sorting
body: <p>I am building a web application using Java EE (although my problem is more Java based) </p>
  
  <p>In a Servlet, I am getting a list of orders from the EJB. In this list of orders, there is a list of states for this order (sent, on dock, non received ...)</p>
  
  <p>I want to sort this list of states by the date of the state. So I use Collections.sort like this: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    for (Command c : commands) {
          c.getStateList().sort(new Comparator&lt;State&gt;() {
                  @Override
                  public int compare(State o1, State o2) {
                      return o1.getStateDate().compareTo(o2.getStateDate());
                  }
          });
  
          c.getStateList().sort(Collections.reverseOrder());
      }
  request.setAttribute("commands", commands);</code></pre>
  </div>
  </div>
  </p>
  
  <p>But when I display the results, the states are not sorted. </p>
  
  <p>I tried to reverse the order as you can see, but it isn't working either. </p>
  
  <p>As you can also see, I replaced the Collections.sort with the ListIWantToSort.sort. Still not working. </p>
  
  <p>Any ideas on why it does not work or how I could repair it? </p>
  
  <p><strong>EDIT</strong> : Here is the getter for the list and its instanciation : </p>
  
  <pre class="lang-java prettyprint-override"><code>    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ciiCommande")
      private List&lt;Etat&gt; etatList;
  
      @XmlTransient
      public List&lt;Etat&gt; getEtatList() {
          return etatList;
      }
  
      List&lt;Commande&gt; commandes = new ArrayList&lt;Commande&gt;();
  </code></pre>
  
  <p>And I get my commands by a findAll Method. </p>
  
  <p>To display them, I use that : </p>
  
  <pre class="lang-java prettyprint-override"><code>&lt;c:forEach items="${commandes}" var="cmd"&gt;
      &lt;td&gt;${cmd.etatList[0].codeStatut.libelleSituation}&lt;/td&gt;
  &lt;/c:forEach&gt;
  </code></pre>