grr/core/grr_response_core/lib/util/collection.py
def Group(items, key):
  """Groups items by given key function.

  Args:
    items: An iterable or an iterator of items.
    key: A function which given each item will return the key.

  Returns:
    A dict with keys being each unique key and values being a list of items of
    that key.
  """
  result = {}

  for item in items:
    result.setdefault(key(item), []).append(item)

  return result
Groups items by given key function.

  Args:
    items: An iterable or an iterator of items.
    key: A function which given each item will return the key.

  Returns:
    A dict with keys being each unique key and values being a list of items of
    that key.
  
Groups items by given key function.
Groups items by given key function .
def Group(items, key):
  result = {}
  for item in items:
    result.setdefault(key(item), []).append(item)
  return result
def Group ( items , key ) : result = { } for item in items : result . setdefault ( key ( item ) , [ ] ) . append ( item ) return result
Groups items by given key function.
Groups items by given key function .
"""Groups items by given key function.

  Args:
    items: An iterable or an iterator of items.
    key: A function which given each item will return the key.

  Returns:
    A dict with keys being each unique key and values being a list of items of
    that key.
  """
A dict with keys being each unique key and values being a list of items of
that key.
A dict with keys being each unique key and values being a list of items of that key .
items
An iterable or an iterator of items.
An iterable or an iterator of items .
key
A function which given each item will return the key.
A function which given each item will return the key .