nodes: 0, module; 1, function_definition; 2, function_name:groupby; 3, parameters; 4, block; 5, identifier:itr; 6, default_parameter; 7, expression_statement; 8, return_statement; 9, identifier:key_fn; 10, None; 11, comment:"""
      An wrapper function around itertools.groupby to sort each results.
  
      :param itr: Iterable object, a list/tuple/genrator, etc.
      :param key_fn: Key function to sort 'itr'.
  
      >>> import operator
      >>> itr = [("a", 1), ("b", -1), ("c", 1)]
      >>> res = groupby(itr, operator.itemgetter(1))
      >>> [(key, tuple(grp)) for key, grp in res]
      [(-1, (('b', -1),)), (1, (('a', 1), ('c', 1)))]
      """; 12, call; 13, attribute; 14, argument_list; 15, identifier:itertools; 16, identifier:groupby; 17, call; 18, keyword_argument; 19, identifier:sorted; 20, argument_list; 21, identifier:key; 22, identifier:key_fn; 23, identifier:itr; 24, keyword_argument; 25, identifier:key; 26, identifier:key_fn
code: def groupby(itr, key_fn=None):
      """
      An wrapper function around itertools.groupby to sort each results.
  
      :param itr: Iterable object, a list/tuple/genrator, etc.
      :param key_fn: Key function to sort 'itr'.
  
      >>> import operator
      >>> itr = [("a", 1), ("b", -1), ("c", 1)]
      >>> res = groupby(itr, operator.itemgetter(1))
      >>> [(key, tuple(grp)) for key, grp in res]
      [(-1, (('b', -1),)), (1, (('a', 1), ('c', 1)))]
      """
      return itertools.groupby(sorted(itr, key=key_fn), key=key_fn)