Hello there, thank you for reaching us out!
A good approach here would be to add a new boolean attribute that specifies if the car has a price or not.
This attribute could be
price == 0 or
price == nil, set this boolean to false.
Having this new
has_price attribute, you can add it to your ranking formula to make sure
has_price == false are always retrieved last. This would be a “sort_by” attribute on
has_price, ascending, at the top of your ranking formula. It should look like
asc(has_price), first element of your ranking formula.
Here is some documentation with a similar case (for filtering instead of sorting): https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/how-to/filter-by-null-or-missing-attributes/
And the documentation for the ranking formula: https://www.algolia.com/doc/api-reference/api-parameters/ranking/
Let us know if this works for you, have a nice day!