dnd 5e – How does turn order work for the Beast Master ranger’s alternative class feature Primal Companion?

This only works if your race is size Small.

The rules for mounted combat state:

A willing creature that is at least one size larger than you and that has an appropriate anatomy can serve as a mount, using the following rules.

The three types of primal companions are medium or smaller, so your race must be small to be able to use the primal companion as a mount.

Provided you are able to ride the creature by being the appropriate size, it seems the rules support the turn you describe. There are two ways to get your companion to take the Attack action:

you take a bonus action on your turn to command it to take another action.

Or,

You can also sacrifice one of your attacks when you take the Attack action to command the beast to take the Attack action.

Doing one of these two things produces the desired result. Just be careful:

if the mount provokes an opportunity attack while you’re on it, the attacker can target you or the mount.