Site icon Hip-Hop Website Design and Development

How can I use arrays and a foreach to generate many lists with WP_Query?

I have a number of posts that I would like to show in a sorted list according to two properties.
I want the end product to look like this:

    1. Florida
      A.  National Parks
         -list of parks
      B. Local Parks
         -list of parks
    2. Pennsylvania
      A. National Parks
         -list of parks
      B. Local Parks
         -list of parks

Right now I have a WP_Query that works for one park:

                    $the_query = new WP_Query(array(
                        'post_type'         => 'park',
                        'location'          => 'Florida',
                        'park_type'         => 'national park',
                        'posts_per_page'    => -1,
                        'meta_key'          => 'park_official_name',
                        'orderby'           => 'meta_value',
                        'order'             => 'DESC'
                    ));

            ?>
            <?php if( $the_query->have_posts() ): ?>
                
                <ul>
                
                    <?php while( $the_query->have_posts() ) : $the_query->the_post(); 
    
                    $class = get_field('park_type') ? 'class="park_type"' : '';
    
                    ?>
                    
                        <li <?php echo $class; ?>>
                            <a href="<?php the_permalink(); ?>"><?php the_field('park_official_name'); ?></a>
                        </li>
                
                    <?php endwhile; ?>
                
                </ul>
                
            <?php endif; ?>

            <?php  wp_reset_postdata();

I am not very good with foreach loops and can’t see how to get this from where it is to something that will loop through each park and put it in the right list. Any ideas?