Randomize listing order code still dysfunctional

This code randomizes the listings if you go to all categories from the homepage, but if you click on an individual category from the homepage, it doesn’t perform the function.

add_filter( 
 	'posts_orderby', 
 	function($orderby, $query){
  		if ( $query->get( 'post_type' ) === 'hp_listing' && is_post_type_archive('hp_listing') && empty($_GET['_sort']) ) {
   			$orderby = 'RAND()';
  		}

  		return $orderby;
 	}, 
 	10, 
 	2 
);

Is there an alternative that would solve this problem? Thank you!