If you are aiming 5800x3d, then CPU first.
Make sure your update your motherboard bios before the upgrade.
Agreed, go for the 58003D first. I would have said go for the graph card but five reasons to go CPU first:
1- The 5800x3D will max your CPU options out for your MB, so that's out of the way for the next step. I would even consider upgrading RAM to 32GB DDR4 4600 for $89 for fully maxed out system
2- The 5800x3D is $299 right now, roughly $400 for CPU + RAM. No graphic card is interesting below $700 imo
3- The graphic cards options are not really interesting in general this generation (4700Ti too low on VRAM, 7900XT not good for RT, 4080 too expensive for 16GB)
4- You WILL HAVE TO upgrade your CPU to get the best out of your mobo eventually, and there will not be other options but the 5800x3D. However, there will be much better options for graph card end of next year / early 2025
5- You can play all games maxed out with a 2800 and a 5800x3D in HD, that should be enough with DLSS to be decent in 1440p.
This way, you get a nice +30%/%40 gain (see link below) while waiting a year of so for the next gen graph card and have a futureproof computer for the next 5 years +.

AMD Ryzen 7 5800X3D Review - The Magic of 3D V-Cache
The AMD Ryzen 7 5800X3D is the company's new flagship gaming processor. It introduces 3D V-Cache, a dedicated piece of silicon with additional L3 capacity. In our review, we're testing how much the larger cache can help intensive gaming workloads and applications and compare it to the Intel Core...