code: def transform_sort(self, node, results):
      sort_stmt = results["sort"]
      next_stmt = results["next"]
      list_call = results.get("list")
      simple_expr = results.get("expr")
  
      if list_call:
          list_call.replace(Name("sorted", prefix=list_call.prefix))
      elif simple_expr:
          new = simple_expr.clone()
          new.prefix = ""
          simple_expr.replace(
              Call(Name("sorted"), [new], prefix=simple_expr.prefix)
          )
      else:
          raise RuntimeError("should not have reached here")
      sort_stmt.remove()
  
      btwn = sort_stmt.prefix
      # Keep any prefix lines between the sort_stmt and the list_call and
      # shove them right after the sorted() call.
      if "\n" in btwn:
          if next_stmt:
              # The new prefix should be everything from the sort_stmt's
              # prefix up to the last newline, then the old prefix after a new
              # line.
              prefix_lines = (
                  btwn.rpartition("\n")[0],
                  next_stmt[0].prefix,
              )
              next_stmt[0].prefix = "\n".join(prefix_lines)
          else:
              assert list_call.parent
              assert list_call.next_sibling is None
              # Put a blank line after list_call and set its prefix.
              end_line = BlankLine()
              list_call.parent.append_child(end_line)
              assert list_call.next_sibling is end_line
              # The new prefix should be everything up to the first new line
              # of sort_stmt's prefix.
              end_line.prefix = btwn.rpartition("\n")[0]
  
file_path: catboost/contrib/tools/python/src/Lib/lib2to3/fixes/fix_idioms.py
imports: from ..None import fixer_base
  from ..fixer_util import Call, Comma, Name, Node, BlankLine, syms
label_desc: Use image node_id 5 for calling the FixIdioms obj's underlying member method code with example usage: obj.transform_sort(node, results) without return types