// Sorting by meta query alias keys

If you’re familiar with WP_Query, you’ve probably already used the meta_query syntax:

$args = array(
    'post_type' => 'cars',
    'post_status' => 'publish',
    'meta_query' => array(
        array(
            'key' => 'featured_sales',
            'compare' => 'EXISTS'
        )
    )
);

But did you know that you can give each meta_query segment a unique key:

$args = array(
    'post_type' => 'cars',
    'post_status' => 'publish',
    'meta_query' => array(
        'is_featured_sales' => array(
            'key' => 'featured_sales',
            'compare' => 'EXISTS'
        )
    )
);

And use this key within the orderby clause?

$args = array(
    'post_type' => 'cars',
    'post_status' => 'publish',
    'meta_query' => array(
        'is_featured_sales' => array(
            'key' => 'featured_sales',
            'compare' => 'EXISTS'
        )
    ),
    'orderby' => array(
        'is_featured_sales' => 'DESC'
    )
);

David Cramer noticed this handy feature, which was added back in WordPress 4.2.