Collections Sort Issue in Java
<p>To put it simply, I have a list of weeks <code>ArrayList&lt;Week&gt;</code>, each of which contains a list of days <code>ArrayList&lt;Day&gt;</code>, each of which contains a Date object within the Day class. In other words, Weeks, have Days, have Dates.</p>

<p>For a problem I have to randomize the <code>ArrayList&lt;Week&gt;</code>, which I use Collections.shuffle for and works fine.</p>

<p>I then need to put them back in order, and I attempted this with:</p>

<pre><code>public void sortWeeksInDateOrder(final List&lt;Week&gt; weeks) {
Collections.sort(weeks, new Comparator&lt;Week&gt;() {
        @Override
        public int compare(final Week week1, final Week week2) {
        //Return -1 or 1 if first date is before or after second date.
            return week1.getAllDays().get(0).getDate().before((week2.getAllDays().get(0).getDate())) ? -1 : 1;
        }
    });
}
</code></pre>

<p>However it's not sorting. Am I missing something? The weeks are never the same so I don't need to return a 0, so I thought this solution would work.</p>