The timeline of this is simple, after link slays Ganon, he is trapped in the dark world. So in
AlttP, Link beats Ganon in the dark world.
On another note, it could happend before
OoT because Ganon takes over the sacred relam, and turns it into the dark world. But once Link slays him? Is
AlttP the farthest Zelda in the timeline? Or could Ganon be like Link, he is always different?