put the cart before the horse
To put things in the wrong order or with the wrong priorities; to put something inconsequential as more important than something more essential.
The hour had struck; and with it, as always, appeared the man. So it has ever been in the history of the world; though we, with characteristic vanity, uniformly put the cart before