 <p>This is just complicated code for no reason..</p> <pre><code>public class Sort { public static void calc(ArrayList&lt;Book&gt; bookList) { for (i = 0 ; i &lt; bookList.size() ; i++) { for (j = i+1; j &lt; bookList.size() ; j++) { if (bookList.get(i).getRating() &gt; bookList.get(j).getRating()) { Collections.swap(bookList, i, j); } System.out.println(bookList.get(out).getTitle() + " " + bookList.get(out).getRating()); } } } } </code></pre> <p>Hope that helps</p>