Sort Objects in Array by date
<p>I have an array containing an object called <code>HistoryObject</code> and it has properties such as "date", "name", etc.</p>

<p>I am sorting the array like so:</p>

<pre><code> let sortedArray = HistoryArray.sort({ $0.date.compare($1.date) == NSComparisonResult.OrderedDescending})
</code></pre>

<p>which is supposed to sort the date from newer to oldest. For example: </p>

<ul>
<li>Jun 30, 2016</li>
<li>Jun 29, 2016</li>
</ul>

<p>etc..</p>

<p>But when my array contains "Jul 2, 2016" the sorted array becomes:</p>

<ul>
<li>Jun 30, 2016</li>
<li>Jun 29, 2016</li>
<li>Jul 2, 2016</li>
</ul>

<p>Where "Jul 2, 2016" should be on top after sorting, now it's on the bottom? How can I fix this problem?</p>