code: def group(iterable, key):
      
      for _, grouped in groupby(sorted(iterable, key=key), key=key):
          yield list(grouped)
docs: groupby which sorts the input, discards the key and returns the output
      as a sequence of lists.