title: Sort an array by NSDates using the sort function
body: <p>I have a model class called <code>Event</code>.</p>
  
  <pre><code>import Foundation
  import MapKit
  
  public class Event {
  
      let id: Int
      var title: String?
      let status: String
      let location: String
      var description: String?
      var latitude: CLLocationDegrees?
      var longitude: CLLocationDegrees?
      var startDate: NSDate?
      var endDate: NSDate?
  
  
      init(id: Int, location: String, status: String) {
          self.id = id
          self.location = location
          self.status = status
      }
  
  }
  </code></pre>
  
  <p>I get the events data from a web API as a JSON response. Then I create <code>Event</code> objects from parsing the JSON data and put them in an typed array (<code>var events = [Event]()</code>). </p>
  
  <pre><code>private func processEventData(data: JSON) {
      var events = [Event]()
  
      if let eventsArray = data.array {
          for eventObj in eventsArray {
              let event = Event(
                  id: eventObj["id"].int!,
                  location: eventObj["location"].string!,
                  status: eventObj["status"].string!
              )
              event.title = eventObj["title"].string
              event.description = eventObj["description"].string
              event.latitude = eventObj["lat"].double
              event.longitude = eventObj["lng"].double
              event.startDate = NSDate(string: eventObj["start"].string!)
              event.endDate = NSDate(string: eventObj["end"].string!)
  
              events.append(event)
          }
  
      }
  }
  </code></pre>
  
  <p>Next I need to sort this array by the <code>startDate</code> property value. I tried sorting the array using the new Swift standard library function <code>sort</code> like this.</p>
  
  <pre><code>var orderedEvents = events.sort({ $0.startDate! &lt; $1.startDate! })
  </code></pre>
  
  <p>But strangely I get the following error.</p>
  
  <p><strong>Cannot invoke 'sort' with an argument list of type '((_, _) -> _)'</strong></p>
  
  <p>I don't understand why I cannot sort it this way because I have a typed array. </p>
  
  <p>Any idea what I'm doing wrong here?</p>