Adding sorting to branches