It probably depends on the problem size, sorting is a much more expensive operation than min/max, and you will feel that with large inputs.
On the other hand, for small problems, you would probably not overthink optimizing this, anyways.
You might also see if the advanced jit fusers optimize this, I think they are capable of this, but I don’t know if they do it.
If you don’t need gradients, there also is the relatively new, undocumented torch._aminmax.