Filtering WP_Query

I rewrote the code and now it works

The loop:

$args = array('post_type' => 'artist');
$wp_query = new WP_Query( array_merge( $args, array('nopaging' => true) ) );

The filter:

function theme_posts_orderby( $orderby, $query )
{
    if ($query->query_vars['post_type'] == 'artist') {
        // order artists by last name
        $orderby = "RIGHT(post_title, LOCATE(' ', REVERSE(post_title)) - 1) ASC";
    }
    return $orderby;
}
add_filter('posts_orderby', 'theme_posts_orderby', 10, 2 );