How to sort queried pages by an array of page ids?

There is no need to use such custom code when wordpress provides a better way of ordering the pages using menu_order. You can see this option under Page Attributes box on the right side of page edit screen. You can assign the ordering as per your criteria, then use the following code

<?php
global $wp_query;
$wp_query = new WP_Query(
                    array(
                        'post_type' => 'page',
                        'orderby' => 'menu_order',
                        'order' => 'ASC'
                    )
                );
while ( have_posts() ) : the_post(); ?>

    <?php get_template_part( 'content', 'page' ); ?>

<?php endwhile; ?>

Few things to note:

  • As per your ordering of the page titles in the array, you should assign the 1st element the least order and the other elements the higher order as per their sequence.