title: Comparator for list on a specific item's field
body: <p>I have a List element.</p>
  
  <p>Every OrderType item has an integer field, priority, that set the priority (1, 2 or 3) of the reassortment of the list.</p>
  
  <p>I want create a comparator that reassort the list from priority 1 to 3. Can I use the <em>Collections.sort</em> method?</p>
  
  <p>I saw this example:</p>
  
  <pre><code>package com.javacodegeeks.example;
  
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.List;
  
  public class SimpleSortExample {
  
      public static void main(String[] args) {
          List list = new ArrayList();
  
          for (int i=0;i&lt;10;i++) {
              list.add((int) (Math.random() * 100));
          }
  
          System.out.println("Initial List: "+list);
          Collections.sort(list);
          System.out.println("Sorted List: "+list);
  
      }
  
  }
  </code></pre>
  
  <p>There are some examples <a href="http://examples.javacodegeeks.com/core-java/util/list/java-sorted-list-example/" rel="nofollow">here</a>.</p>
  
  <p>How can I do this?</p>
  
  <p>I tried with:</p>
  
  <pre><code>Collections.sort(list, new Comparator() {
  
          @Override
          public int compare(Integer i1, Integer i2) {
              return (i2.intValue() &gt; i1.intValue()) ? 1 : -1;
          }
  
      });
  </code></pre>
  
  <p>but I obtain an error, I have to implement the not ovveride method <em>compare(object, Object)</em>...</p>
  
  <p>Like <em>compare(Integer, Integer)</em> is not an override method.</p>