 <p>You can make the database sort for you! </p> <p><code>Product.order(name: :asc, status: :desc)</code></p> <p>Check out the guide here <a href="http://guides.rubyonrails.org/active_record_querying.html#ordering" rel="nofollow">http://guides.rubyonrails.org/active_record_querying.html#ordering</a> for more information</p>