Selling first gives you a firm number for the smaller purchase and avoids carrying two mortgages, but if the dates cannot be lined up, you may need short-term housing in between.
Buying first protects you from a rushed move but depends on a lender agreeing you can carry both properties temporarily, which is a real underwriting hurdle, not a formality.
A lawyer, typically for $800 to $1,500, is the one who can actually tell you whether same-day possession is realistic for your specific two transactions. Get your hand-reviewed valuation from Joel Dyck.