List Post Title by Last Word Then Second Last

I think I got it!!!

Try this:

 $orderby = " SUBSTRING_INDEX( {$wpdb->posts}.post_title, ' ', -1 ) " . $get_order. " , {$wpdb->posts}.post_title " . $get_order;

Basically it’s sorting by lastname and then first name in 1 query.

So, your whole code would be:

add_filter( 'posts_orderby', function( $orderby, \WP_Query $q )
{
if( 'wpse_last_word' === $q->get( 'orderby' ) && $get_order =  $q->get( 'order' ) )
{
    if( in_array( strtoupper( $get_order ), ['ASC', 'DESC'] ) )
    {
        global $wpdb;

       $orderby = " SUBSTRING_INDEX( {$wpdb->posts}.post_title, ' ', -1 ) " . $get_order. " , {$wpdb->posts}.post_title " . $get_order;
    }
}
return $orderby;
}, PHP_INT_MAX, 2 );