nodes: 0, module; 1, function_definition; 2, function_name:sorted_outrows; 3, parameters; 4, comment:# type: (Iterable[InstalledCSVRow]) -> List[InstalledCSVRow]; 5, block; 6, identifier:outrows; 7, expression_statement; 8, comment:# Normally, there should only be one row per path, in which case the; 9, comment:# second and third elements don't come into play when sorting.; 10, comment:# However, in cases in the wild where a path might happen to occur twice,; 11, comment:# we don't want the sort operation to trigger an error (but still want; 12, comment:# determinism).  Since the third element can be an int or string, we; 13, comment:# coerce each element to a string to avoid a TypeError in this case.; 14, comment:# For additional background, see--; 15, comment:# https://github.com/pypa/pip/issues/5868; 16, return_statement; 17, comment:"""
      Return the given rows of a RECORD file in sorted order.
  
      Each row is a 3-tuple (path, hash, size) and corresponds to a record of
      a RECORD file (see PEP 376 and PEP 427 for details).  For the rows
      passed to this function, the size can be an integer as an int or string,
      or the empty string.
      """; 18, call; 19, identifier:sorted; 20, argument_list; 21, identifier:outrows; 22, keyword_argument; 23, identifier:key; 24, lambda; 25, lambda_parameters; 26, call; 27, identifier:row; 28, identifier:tuple; 29, generator_expression; 30, call; 31, for_in_clause; 32, identifier:str; 33, argument_list; 34, identifier:x; 35, identifier:row; 36, identifier:x
code: def sorted_outrows(outrows):
      # type: (Iterable[InstalledCSVRow]) -> List[InstalledCSVRow]
      """
      Return the given rows of a RECORD file in sorted order.
  
      Each row is a 3-tuple (path, hash, size) and corresponds to a record of
      a RECORD file (see PEP 376 and PEP 427 for details).  For the rows
      passed to this function, the size can be an integer as an int or string,
      or the empty string.
      """
      # Normally, there should only be one row per path, in which case the
      # second and third elements don't come into play when sorting.
      # However, in cases in the wild where a path might happen to occur twice,
      # we don't want the sort operation to trigger an error (but still want
      # determinism).  Since the third element can be an int or string, we
      # coerce each element to a string to avoid a TypeError in this case.
      # For additional background, see--
      # https://github.com/pypa/pip/issues/5868
      return sorted(outrows, key=lambda row: tuple(str(x) for x in row))