Towards the end of Avengers: Infinity war, after

>! Thor managed to re-light the forge and create Stormbreaker

Thor, Rocket, and Groot 

>! use the Bifrost ability of the newly forged weapon to go to Wakanda.

They land exactly in the middle of where they're needed. I understand Thor knew their next stop should be Earth, but how could he possibly know to take them directly to
>! Wakanda?