Sort messages by time