Add sorting to messages