The answer depends on two things: (1) how far apart you’re planning on buying and selling, and (2) your market outlook. If you plan on buying and selling close together, it shouldn’t matter which comes first. However, if you plan on buying and selling far apart, you’ll need to consider where you think the housing market is going.
For example: If you housing market is at historic highs, but you expect prices to drop in the future, it would make sense to sell your existing home now at high prices and then buy later at the lower prices. On the flip side, if you expect property prices to continue to go up, you’d want to buy your new house now and sell your old house after to benefit from the increase in prices.
Of course, no one has a crystal ball to predict the housing market, so the safest, least risky route is to buy and sell close together in the same market.