Sort messages by date before looking for the last message.