precedence sort