import collections


def _GroupByCategory(results):
  """Group results by their `category` field."""
  categories = collections.defaultdict(list)
  for result in results:
    categories[result['category']].append(result)
  return categories