Hi Artem,
It depends on the type of join that is used.
Basically, the data can be sorted using a temp table (in tempdb database) or in memory (procedure cache). The data cache is not used for that purposes.
It depends on the plan that is used and the optimization goal.
Do you have a particular problem you want to solve? Do you have a query is not working properly?
regards,
Adam