Order posts by 2 custom fields and if one custom field is zero orderby another custom field

Well let me answer my own question, this may not be perfect, but it works

First I query the posts using WP_query normally, and then I build an associative array by myself including 2 values, one is post ID another one is the order(I merge 2 order fields into one here)

then I use “uasort” to sort the associative array I built based on merged order, so now I have an array with ordered post ID value

then I use WP_query to query again, this time I query use “post_in” array that I have sorted and then orderby => “post_in”, so I got the results I want(in correct order)

This is a very specific case and hope this may help someone future

the key is the query variable “post_in” and you can order by “post_in” array, so in this way, you can query posts whatever order you want as long as you build a “post_in” array, like below

$args = array(
'post_type' => 'accommodation',
'post_parent' => $parent,
'post__in' => $ordered_array, 
'orderby' => 'post__in',

)

thanks