(Swift 3) Trying to sort an array of class objects by Date in swift 3?
<p>I have an array of objects that has a member that is type <code>Date</code>, and I'm trying to sort the whole array by <code>Date</code>, and it's not sorting correctly.
This is the code I'm using, the name of the array is <code>alarms</code> and the name of the member type <code>Date</code> is <code>time</code>.</p>

<pre><code>alarms.sort(by: { $0.time.compare($1.time) == .orderedAscending })
</code></pre>

<p>and whenever I sort it it just doesn't work correctly, and I'm testing it by printing all the values in a <code>for</code> loop.</p>

<p>Can someone help me with the syntax for this?</p>