title: Drupal EntityFieldQuery group results by taxonomy
body: <p>I have an entity bundle called Map Points that has a taxonomy term reference field of countries. I'm using EntityFieldQuery in a custom module to list out all the map point entities but I need to group them by the country reference field. </p>
  
  <p>Here is the code I have right now which filters the query by tid 1 and I know I can repeat the query for each country to group the results but I'm looking for a more refined way to group the results by the country term id's without having to write a new query for each country.</p>
  
  <pre><code>$query = new EntityFieldQuery();
  $query
      -&gt;entityCondition('entity_type', 'givepower')
      -&gt;entityCondition('bundle', 'map_points')
      -&gt;propertyCondition('type', 'map_points', '=')
      -&gt;fieldCondition('field_map_point_country', 'tid', '1');
  
  $result = $query-&gt;execute();
  
  // set empty map point id array
  $map_point_ids = array();
  // loop through all givepower entities
  foreach($result['givepower'] as $record) {
      $map_point_ids[] = $record-&gt;id;
  }
  // load entities
  $map_point = entity_load('givepower', $map_point_ids);
  // set entity view
  $entities = entity_view('givepower', $map_point);
  
  
  return $entities;
  </code></pre>