I have an array of messages that I want to sort by whether they are unread or not, and their time stamp. These messages will be displayed in a TableView.
All unread messages should be displayed at the top, and then sorted by their timestamp.
Below is what I have right now; but what seems to be happening is that the items are displayed only by time stamp, without sorting them by unread at the top and then unread messages after.
let channelsSortedByUnreadFirst = dataStore.messages.sorted { $0.isUnread == true && $1.isUnread == false }
let timeSortedItems = channelsSortedByUnreadFirst.sorted(by: { $0.timeStamp > $1.timeStamp })
messagesTableViewSection.items = timeSortedItems
How do I sort these messages by both isUnread and timeStamp?