Featured and not featured post in the same loop in random order

Hi!
Can anyone help with the following task:

  • i have an acf custom post type called “accommodations”
  • some of the accomodations needs to be featured
  • i made an acf checkbox field, field name “featured” value “Yes” if it is checked
  • I need a loop, that list all the accomodations with the featured posts on top in random order, and the rest afterwards also in random order
  • The loop must be able to filtered based on other acf fields, for example “number of apartments”, “services”… etc. I want to use Bricks Filter & Live Search for that.
  • it is a multilanguage site translated with wpml, so it needs to be working in all language

I tried a loop with meta query, writing custom php or custom query type in functions.php. Chatgpt could not help. No success so far.
What is the best way to do this?

I have a code (based on this), that almost works, but the random order does not (kiemelt = featured).
(I am not a programmer.)

add_filter( 'bricks/posts/query_vars', function( $query_vars, $settings, $element_id, $element_name ) {
    
    // list all the elements' IDs here
   $elements = array(
       'oxobdl',
   );

   // Check if the element_id is inside the array
   if ( !in_array($element_id, $elements)) {
      return $query_vars;
   }
   
   // Apply the custom query var
   $query_vars['meta_query'] = [
        'relation' => 'AND',
        'kiemeltek' => array(
            'key' => 'kiemelt',
            'compare' => 'EXISTS',
        ),
        'nem_kiemeltek' => array(
            'key' => 'kiemelt',
            'compare' => 'NOT_EXISTS',
        ), 
    ];
    
    // Set order
    $query_vars['orderby'] = [
        'kiemeltek' => 'RAND',
        'nem_kiemeltek' => 'RAND'
    ];

   // return the modified query var

    return $query_vars;
}, 10, 4 );

Thanks!