What are the reasons that the optimizer chooses to insert a sort operator in the plan (to satisfy a stream aggregate or a merge join, etc.) instead of going for hash match or hash join?
I have now see a couple of examples where it obviously makes a mistake and hinting the query will make it a lot faster.
The examples I have seen are from SQL Server 2016.