please check following link for help.
Our app, Push Down & Hide Out of Stock, does exactly what you want!
You can move out-of-stock products to the bottom of the collection with our app. It has an easy setup, and all processes automatic.
If you have any questions, please don't hesitate to reach out to us at email@example.com