It can be done in several orders.
Some people do their IR before the CPL, which is fine.
I'm planning CPL before IR, because if I get to the end of my CPL and the job market is still pants, at least I have a commercial licence to earn money from, rather than just a PPL-ME-IR which is worth nothing.
You can slot the ME in anywhere, as long as it's before the IR, and you can do the CPL in a multi and include it in one test.