title: Sorting Object ArrayList using Collections.sort
body: <p>I have added some <code>Integer</code>s to an <code>ArrayList</code> of object type, and want it to be sorted. My code looks like:</p>
  
  <pre><code>List&lt;Object&gt; list = new ArrayList&lt;Object&gt;(); 
  
  list.add(24);
  list.add(2);
  list.add(4);
  
  Collections.sort(list);  // getting error here
  
  System.out.println("Sorted list  ");
  
  for (Object e : list) {
      System.out.println(e);
  }
  </code></pre>
  
  <p>I got the following compile-time error:</p>
  
  <blockquote>
  <pre><code>error  : should implement java.lang.Compareble &lt;? super java.lang.Object&gt;
  </code></pre>
  </blockquote>
  
  <p>How should I resolve this issue?</p>