Ordering depending on distance selection

<?php

add_filter( 'facetwp_query_args', function( $query_args, $class ) {
    if ( 0 < count( $class->facets['distance']['selected_values'] ) ) {
        $query_args['orderby'] = 'post__in';
        $query_args['order'] = 'ASC';
    }
    return $query_args;
}, 10, 2 );