docs: def render_stats(stats, sort, format):
      """
      Returns a StringIO containing the formatted statistics from _statsfile_.
  
      _sort_ is a list of fields to sort by.
      _format_ is the name of the method that pstats uses to format the data.
      """
      output = StdoutWrapper()
      if hasattr(stats, "stream"):
          stats.stream = output.stream
      stats.sort_stats(*sort)
      getattr(stats, format)()
      return output.stream