Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to write a <a href="http://java.sun.com/javase/6/docs/api/java/util/Comparator.html" rel="nofollow noreferrer"><code>Comparator&lt;MyObject&gt;</code></a> and use <a href="http://java.sun.com/javase/6/docs/api/java/util/Collections.html#sort%28java.util.List,%20java.util.Comparator%29" rel="nofollow noreferrer"><code>Collections.sort(List&lt;T&gt;, Comparator&lt;? super T&gt;</code></a> to sort your <code>List</code>.</p> <p>Or else, your <code>MyObject</code> can also <a href="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html" rel="nofollow noreferrer"><code>implements Comparable&lt;MyObject&gt;</code></a>, defining a <em>natural ordering</em> that compares on your specific attribute, and then use <a href="http://java.sun.com/javase/6/docs/api/java/util/Collections.html#sort%28java.util.List%29" rel="nofollow noreferrer"><code>Collections.sort(List&lt;T&gt;</code></a> instead.</p> <h3>See also</h3> <ul> <li><a href="http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/collections/interfaces/order.html" rel="nofollow noreferrer">Java Tutorials/Object Ordering</a></li> </ul> <h3>Related questions</h3> <p>On sorting <code>List</code> on various criteria:</p> <ul> <li><a href="https://stackoverflow.com/questions/1814095/sorting-an-arraylist-of-contacts">Sorting an ArrayList of Contacts</a></li> </ul> <p>On <code>Comparator</code> and <code>Comparable</code></p> <ul> <li><a href="https://stackoverflow.com/questions/2266827/when-to-use-comparable-vs-comparator">When to use Comparable vs Comparator</a></li> <li><a href="https://stackoverflow.com/questions/420223/difference-between-compare-and-compareto">difference between compare() and compareTo()</a></li> <li><a href="https://stackoverflow.com/questions/2858628/comparable-and-comparator-contract-with-regards-to-null">Comparable and Comparator contract with regards to null</a></li> <li><a href="https://stackoverflow.com/questions/2892947/why-does-the-java-collections-framework-offer-two-different-ways-to-sort/">Why does the Java Collections Framework offer two different ways to sort?</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload