Near the end of Thor: Ragnarok,
Loki is in Odin's treasury, and puts the crown from the beginning of the movie into the eternal flame in order to start Ragnarok.
However, later on we see him
on the ship with the remaining Asgardians, after Asgard has been destroyed.
How did he get there from where we last saw him?