Querying a custom post type, but not show duplicates

Ahh iv figured out a way to do this:

<?php
    $args = array(
      'post_type'     => 'classes',
      'orderby'       => 'title',
      'posts_per_page' => -1
    );
    $the_query = new WP_Query( $args );
    $unique_titles = array();
    if( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
        $title = get_the_title();
        if( ! in_array( $title, $unique_cities ) ) :
            $unique_titles[] = $title;
    ?>