class Message {
    var date: NSDate?
    var isSender: Bool
    var text: String?
    var friend: Friend?
}

 var messages: [Message]?
 ...


 messages = messages?.sorted(by: { (msg1, msg2) -> Bool in
        return msg1.date?.compare(msg2.date! as Date) == .orderedAscending
      })

Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.