WordPress Alphabetical Sort Loop Issue

I would approach this a bit differently. You’re outputting all pages, so I would just get them all in one go. You can then iterate over each letter, run the loop, and compare the current letter with the page title to see if it matches.

$args = array(
    'post_type' => 'page',
    'posts_per_page' => -1,
    'orderby' => 'title',
    'order' => 'ASC'
);
$all_pages = new WP_Query( $args );

$columns = array(
    range( 'A', 'J' ),
    range( 'K', 'Z' )
);

foreach( $columns as $letters ){

    foreach( $letters as $letter ){

        echo $letter;

        while( $all_pages->have_posts() ){
            $all_pages->the_post();
            $title = get_the_title();
            if( $letter == strtoupper( $title[0] ) ){
                echo $title;
            }
        }
        $all_pages->rewind_posts();
    }

}

wp_reset_postdata();